[Ethereum] Cannot read property ‘match’ or undefined truffle console

soliditytokenstruffle

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.

Best Answer

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") })
Related Topic