I am trying to send ERC20 token using JSON RPC. I am very new in this step and learning. I am using eth_sendTransaction function. What is "value" and "data" option in this case ? Please help


value is the amount of ethereum you want to send (in wei). data is the message that you want to send. When you send your transaction to a smart contract, that message contains its parameters.

  • Suppose I want to send 20 token (ERC 20). what will be the value ? is that 20 ? and what should be the data plz explain.. – Haren Sarma Apr 20 '18 at 16:25
  • No, ERC20 doesn't work that way. When you send ERC20 tokens you have to send a transaction to the contract of that ERC20 token, eg. 0xB8c77482e45F1F44dE1745F52C74426C631bDD52 if you want to send BNB. In particular, you call the transfer(to, amount) function of that contract. With web3 you probably should use a default ERC20 ABI. – mafrasi2 Apr 20 '18 at 16:33
  • where to define the contract in JSON RPC. there is no option found – Haren Sarma Apr 20 '18 at 18:18
  • What do you mean by "define"? – mafrasi2 Apr 20 '18 at 18:38
  • Ok, maybe I can guess what you mean. You send the transaction to the contract, so the contract is the receiver of that transaction. The receiver of the ERC20 tokens is then encoded in the data field (together with the amount of tokens and the function id of transfer(to, amount)). – mafrasi2 Apr 20 '18 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.