I created a contract token using the sample solidity code tutorial. It has a function called transfer to send tokens between accounts:

function transfer(address _to, uint256 _value)

I need to now connect to this contract using web3, and then send a certain number of tokens generated to another account. I've been struggling with how to do this for quite some time and hoping this community could help. Here is what I have thus far...

const Web3 = require("web3");
const web3 = new Web3();
var abi = [ {} ]

var account = web3.eth.accounts.privateKeyToAccount("0x12312312312323132312")

var contract = new web3.eth.Contract(abi).at("0x282828288282828282")
contract.transferFrom('0xa121111211', '0xabbb2b2bb2', 100);

I know I am missing some piece of this. I am relatively new to solidity & web3 so apologies in advance for my ignorance regarding this matter. Any help would be greatly appreciated!

  • Looks like the variable abi is empty when passed to the eth.contract() function.
    – jojeyh
    Oct 25, 2017 at 19:56
  • @jojeyh, the abi is empty in the sample code for the purpose of this post. Maybe I'm misunderstanding your question?
    – Viper
    Oct 25, 2017 at 20:24


Your Answer

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

Browse other questions tagged or ask your own question.