I would like to send amounts of a created token from one address to another. I would like to use eth_sendTransaction:


Creates new message call transaction or a contract creation, if the data field contains code.

    Object - The transaction object

    from: DATA, 20 Bytes - The address the transaction is send from.
    to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to.
    gas: QUANTITY - (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas.
    gasPrice: QUANTITY - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas
    value: QUANTITY - (optional) Integer of the value send with this transaction
    data: DATA - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Ethereum Contract ABI
    nonce: QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.

params: [{
  "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
  "gas": "0x76c0", // 30400,
  "gasPrice": "0x9184e72a000", // 10000000000000
  "value": "0x9184e72a", // 2441406250
  "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"

The Token uses a basic ERC20 compliant function:
    /* Send coins */
    function transfer(address _to, uint256 _value) {
        if (_to == 0x0) throw;                               // Prevent transfer to 0x0 address. Use burn() instead
        if (balanceOf[msg.sender] < _value) throw;           // Check if the sender has enough
        if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
        balanceOf[msg.sender] -= _value;                     // Subtract from the sender
        balanceOf[_to] += _value;                            // Add the same to the recipient
        Transfer(msg.sender, _to, _value);                   // Notify anyone listening that this transfer took place

Some other questions here are close and help with eth_call, but not to send transactions.

How to call a contract method using the eth_call JSON-RPC API

How can I retrieve my account's Augur (REP) token balance via JSON-RPC?

I see you are supposed to hash the method name, but really no idea how to build up the params to send to the transaction, since it's like adding the first 4 bytes from the hash signature, then adding a left zero padded address.

Please help to build the JSON RPC call for a smart token transaction.

If there is an easy way to do this in web3.py, that would be helpful as well.

1 Answer 1


If there is an easy way to do this in web3.py, that would be helpful as well.

You can create a contract object using a standard EIP20 token ABI, then call it using the generated methods, like:

from web3.contract import ConciseContract

token = web3.eth.contract(

    "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
    "gasPrice": Web3.toWei(4, 'gwei'),

Side Notes:

  1. The transaction from the in-question example sends ether to the token contract. I'm assuming you don't actually want to send 2441406250 wei in ether. The solution above sends 2441406250 tokens instead.
  2. The transaction from the in-question example interacts with a contract at "0xd46e8dd67c5d32be8058bb8eb970870f07244567". The solution above sends the tokens to that address instead. You have to fill in token_contract_address
  3. I dropped the gas price from an exorbitant 10 Terawei to a typically-sufficient 4 Gigawei.
  4. I'm not sure if 30400 is enough gas, so I just removed the parameter. web3.py will estimate it for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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