2

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

2 Answers2

0

From https://programtheblockchain.com/posts/2017/12/29/how-ethereum-transactions-work/:

The following values are encoded:

  • recipient – The account address to which the transaction is being sent.
  • value – The amount of ether to transfer from the sender to the recipient. This amount may be zero.
  • data – Optional arbitrary binary data. During contract deployment, this is where the contract’s bytecode is sent. When calling a function on a contract, this specifies which function should be called and with what arguments. For simple transfers of ether, the data portion of the transaction is typically omitted.
  • gas limit – The maximum amount of gas that can be consumed by the transaction.
  • gas price – The amount the sender will pay for each unit of gas.
  • nonce – A sequence number called a “nonce”. The sequence number is per sender and must match the next available sequence number exactly.
  • signature – Data that identifies and authenticates the transaction’s sender.
user94559
  • 59,196
  • 6
  • 103
  • 103
0

If you want to send ERC20 tokens via RPC calls, you need to call the transfer function of the token contract with correct parameters.

Since ERC20 is not a well-defined standard, but rather an interface I would not recommend doing that blindly, you would have to study the contract source first to make sure it's possible.

To answer your question on a higher level:

  • value is the amount of Ether transferred (in Wei) and should be 0 because you do not want to transfer any ETH.
  • data is the hex-encoded execution of the ERC20 transfer, e.g., the method name called, and it's parameters.

I highly recommend using a wallet that supports ERC20 tokens, such as MyCrypto or Parity, but that is probably not what you are asking for :)

Note, I work for Parity.

q9f
  • 11,293
  • 8
  • 57
  • 96