How to send ERC20 Token?

by minho   Last Updated April 15, 2019 07:28 AM

I try to send Token based on Erc20.

and I can send Ether and something function but i dont know how to use transfer function in javascript like that.

function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }

i did first. const TokenInstance = new web3.eth.Contract(mhToken.abi, '0xC632ecfBBcee37b8061E59fcA11d9cB80DE08612') this.setState({ web3: web3 , MhTokenInstance:MhTokenInstance})

second. using web3 instance i want to send custom token. plz help me how to use transfer function!

Answers 1

These are the steps. Create a web3 Instance

var web3 = new Web3(NODE)

Create a Token Instance

Const TokenInstance = new web3.eth.Contract(TokenABI, TokenAddress)

Sending Transcation

TokenInstance.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
.then((receipt) => {

Which in your case will be

TokenInstance.methods.transfer(address, amount).send({from: senderAddress}.then(receipt => {

Or can use

TokenInstance.methods.transfer(address, amount).send({from: senderAddress})
.on('transactionHash', (hash) => {
.on('receipt', (receipt) => {
.on('confirmation', (confirmationNumber, receipt) => {
.on('error', console.error);
Hamza Ahmed
Hamza Ahmed
April 15, 2019 07:07 AM

Related Questions

Python State Channel client

Updated December 13, 2017 15:28 PM