0

Deploy the ethereum contract token and transfer token from one address to other address using node js web3.Anyone please help me.

1
  • What works and what does not work? Commented Nov 12, 2017 at 15:08

3 Answers 3

0

I found that this article explains well how to do this. source code is available, and you may like to modify it slightly to your purpose.

https://hackernoon.com/how-to-script-an-automatic-token-airdrop-for-40k-subscribers-e40c8b1a02c6

0

Here is the function that generates a transaction that performs an ERC-20 transfer:

async function TransferTokens(_TO, _AMOUNT){
    const ERC_CONTRACT_ADDR = "0x0" // your contract
    const ABI_FILE = "ABI.json"; //your abi
    const ERC_CONTRACT = new web3.eth.Contract(JSON.parse(ABI_FILE), ERC_CONTRACT_ADDR);
    const fromAddress = ""; // your address with tokens
    const fromPrivateKey = "XXX"; //your private key
    return new Promise(async function(resolve, reject){
        let params = await ERC_CONTRACT.methods.transfer(_TO, _AMOUNT).encodeABI();
        let rawTX = await generateTransaction(params, fromAddress, fromPrivateKey, ERC_CONTRACT_ADDR);
        try{
            let hash = await broadcastTransaction(rawTX);
            resolve(hash);
        }catch(e){
            reject(e);
        }
    })

}
0

This tutorial literally explains exactly how to do this.

2
  • We have successfully created contract token using a crypto-currency token code (ethereum.org/token). When transfer token from one address to other address it's not working in Node js but which is works in Geth compiler.We need transfer token using Node js web3.Anyone, please fix this issue. Commented Aug 16, 2017 at 5:08
  • The mentioned article only goes through the token creation, but the question is aimed at using Node to do token transfers.
    – Cyberience
    Commented May 10, 2018 at 10:11

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.