How to call a payable contract function from truffle console

0 votes

I am using the following contract to deposit ethers:

function deposit() payable public {

    balances[msg.sender] = balances[msg.sender].add(msg.value);

    totalBalances.add(msg.value);

}

I have compiled and deployed the contract. I have entered truffle console but I am not understanding how to call this function.

Jan 24, 2019 in Blockchain by MK Bhat
2,288 views

1 answer to this question.

0 votes

You can use a contract function, on a contract that has been deployed, by:

ContractName.at("ContractAddress").FunctionName(FunctionArguments)

So, for your contract, it would be something like this:

ContractName.at("ContractAddress").deposit ()
answered Jan 24, 2019 by Omkar
• 69,210 points

Related Questions In Blockchain

0 votes
1 answer

How to call function in one contract from another contract in private blockchain?

Please check whether you have byzantiumBlock: 0 in your ...READ MORE

answered Oct 1, 2018 in Blockchain by digger
• 26,740 points
694 views
0 votes
1 answer

How is a request sent from an app to a smart contract?

Yes, the contract is distributed by every node ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,100 points
558 views
0 votes
1 answer

How to call smart contract methods from transactions?

You can do this using a wrapper. ...READ MORE

answered Aug 13, 2018 in Blockchain by slayer
• 29,350 points
778 views
0 votes
1 answer

How do I send ether from an EOA to a smart contract?

You include ether to send in the ...READ MORE

answered Sep 27, 2018 in Blockchain by digger
• 26,740 points
1,335 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,662 views
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,210 points
1,237 views
0 votes
2 answers

Why is network already up to date while trying to deploy a contract on truffle?

I guess you have ganache running already ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,400 points
4,107 views
0 votes
1 answer

How can I deploy a HelloWorld contract on my testrpc network?

The problem lies in the command: truffle migrate Your truffle migrate command ...READ MORE

answered Apr 27, 2018 in Blockchain by Perry
• 17,100 points

edited Aug 10, 2018 by Omkar 2,429 views
0 votes
1 answer

How to run smart contract function using nethereum to return a result?

Try this: var result = getUserAtIndex.CallAsync<byte[]>(123) ...READ MORE

answered Oct 24, 2018 in Blockchain by Omkar
• 69,210 points
1,874 views
0 votes
1 answer

How to create a contract in truffle?

The command you are using to create ...READ MORE

answered Dec 11, 2018 in Blockchain by Omkar
• 69,210 points
1,339 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP