Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Retrieving Ethereum Transaction Data using Javascript

sharmapn

New Coder
From my website, I am trying to retrieve the transaction data stored on the Ethereum blockchain using Javascript.
Rinkeby Transaction Hash (Txhash) Details | Etherscan
If you see the transaction link in the Rinkerby test network, (click to see more) and then Decode the input, the data is hidden and needs to be decoded.
This is the data - which is a hash value, which I would like to retrieve: 6538482db543dedf2b2c2dd986ce475aa2732e24390534c729f749005035e073

I am using the Javascript fetch you retrieve the entire html page. But if I search the resulting htmlString - the data (hash value) is not there. I am not sure how the decoding happens and what piece of data needs to be decoded.

Any assistance on how to get the data (hash value) would be appreciated.

Code:
<html>
<head>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
 <script>
    async function FetchHtml()
    {
      let response = await fetch('https://rinkeby.etherscan.io/tx/0xd8b3c50230fb2f1d3d8586f5179b514e913dbe7868effd490a5743caaabda6b9');
      return await response.text(); // Returns it as Promise
    }

    // Using the HTML
    async function Do()
    {
          let htmlString = await FetchHtml().then(text => {return text});
      console.log(htmlString)
      let position = htmlString.search("div id="inputDecode");
      console.log('position: ' + position)
      var pos = htmlString.substring(
                                    position, position + 2000
                                );
    }

  </script>
</head>

<body>
<p id="demo"></p>
<input type="button" value="GetTransactionData" id="myCheck" onmouseover="Do()">
</body>
</html>
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom