[Ethereum] In the JSON RPC API documentation, where is the part about sending ERC20 tokens

json-rpc

I'm looking to use the JSON RPC API to automate the sending of ERC20 tokens. Here is the documentation for it: https://github.com/ethereum/wiki/wiki/JSON-RPC

Does anyone know where the documentation is as it relates to sending ERC20 tokens? Thanks

Best Answer

Sending erc-20 tokens are just calling a transfer function for a token smart code. It's just like calling any othe function of any other smart contract.

To call a function of a contract, you need to use sendTransaction api.

A sample code snippet for calling transfer function of a smart contract is:

var contractAbi = eth.contract(AbiOfContract);
var myContract = contractAbi.at(contractAddress);
// suppose you want to call a function named myFunction of myContract
var getData = myContract.transfer.getData(function parameters);
//finally paas this data parameter to send Transaction
web3.eth.sendTransaction({to:Contractaddress, from:Accountaddress, data: getData});

You can add other parameters like gas, gasPrice in send transaction as well.