With web3js, how do you figure out that there was 40000 tokens transfer from the transaction's hash?
相关问题
- Send Raw Transaction Ethereum infura nodejs npm
- Uncaught Error: Returned values aren't valid,
- Best datatype to store hexidecimal and hex charact
- How to improve smart contact design in order to di
- Solidity - Solidity code to Input JSON Description
相关文章
- Dynamic array in Solidity
- VM Exception while processing transaction: out of
- Private blockchains Vs Hashgraph, Ripple, BigChain
- Test ethereum Event Logs with truffle
- Get token balance with Ethereum RPC?
- Difference between various blockchain protocols [c
- How to get a value from a “Promise” object
- Can we create non-fungible tokens with Hyperledger
Ethereum smart contract transaction input data decoder Uses ethereumjs-abi for decoding. https://github.com/miguelmota/ethereum-input-data-decoder
I will try to show an example how you do this:
lets take this Tx:
This is Tx to a contract that send some amount of token to address The received data from
web3.eth.getTransaction()
input:Now the first 34 bits represent text of the function signature (0xa9059cbb)
The next 256 bit block represent the address we want send the token to:
00000000000000000000000092e707288dc221d864cf4a8c710c143e97225d7d
The second block represent the amount (in hex) of tokens that were sent to the address:
We will convert the hex to decimal with any conversion function or with this web site: https://www.rapidtables.com/convert/number/hex-to-decimal.html
we will see that after the conversion we get 1659305000000000000000 it the number of token that sent to the address.
I hope it help
There's a very good blog post on Medium using the exact method you're interested in.
(Stealing from the post):
input
data fromweb3.eth.getTransaction()
This will return the hex data for the function and parameters sent in the transaction. It will look something like0xa9059cbb0000000000000000000000007adee867ea91533879d083dd47ea81f0eee3a37e000000000000000000000000000000000000000000000000d02ab486cedbffff
.web3.utils
to convert to decimal.