1

Playing around with the default project provided by truffle. I compiled the contracts with truffle compile.Then deployed with truffle migrate and after that switched to the console via truffle console.Any idea what the command line is for sending for instance 10 Metacoins from default account [0] to account [1]? I set the contract object as a variable with var meta = MetaCoin.deployed(). After that I tried meta.sendCoin({from:accounts[0], to:accounts[1], value: 10}) but it seems to be wrong. However I can send Ether with that command using web3.eth.sendTransaction({from:accounts[0], to:accounts[1], value: 10})

1

The contract defines a function with the following signature:

function sendCoin(address receiver, uint amount) returns(bool sufficient)

In order to send coins to another address you will call it like this:

meta.sendCoin(accounts[1], 10, {from: accounts[0]});

The curly braces define the account used as the "owner", you can also specify the amount of gas that can be used. The first two parameters are specific to the method signature.

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.