2

I want to interact with my contracts through truffle console. I am using test rpc and web3.

Basically for a standard token contract:

contract Token{
       function Token() payable{...}
       function _transfer(...) internal {...}
       function transfer (..) payable{..}
}

i use those command lines in the truffle console:

var contract=null;

Token.new({ from: web3.eth.accounts[0], value: web3.toWei(100, "ether") }).then(function(_contract) { contract = _contract; });

contract.transfer('address of another testrpc accounts', 10, { from: web3.eth.accounts[0], value: web3.toWei(100, "ether") })

Then i got a "Cannot read property 'match' or undefined truffle console" error.

I am lost now because the getters of my contract are actually working.. (ex: token.get_balance.call(..) )

Any idea? Does the syntax of truffle console has changed recently?

Thks.

1

I'm pretty sure you need to specify the to field in the data.

So if you were to move funds from your coinbase account to your second account you would do:

contract.transfer(web3.eth.accounts[1], 10, { from: web3.eth.accounts[0],to:web3.eth.accounts[0], value: web3.toWei(100, "ether") })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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