In remix ide, we have UI designed in such a way that we can pass ether or Wei directly and execute the functions. When we use truffle to deploy the contract, how can we pass ether?


Creating a contract and sending ether in truffle (ganache)

In order to create and send some ether to a contract, you need to call the .send function on the contract.


The following command will create a new instance of MyContract, then call it's .send function with the amount of ether to send and the address from which to send it:

MyContract.new().then(c => c.send(10, {from: web3.eth.accounts[0]}))

Funded account addresses:

When ganache starts it will create 10 different addresses for you each of which contain 100 ether. You can access them via web3.eth.accounts[0..9] and can get their balances like:

  • If this answered your question, please mark it as the correct answer. If not let me know so I can further assist.
    – norganna
    Apr 2 '18 at 3:09

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.