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 in Blockchain by MK Bhat
74 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 by Omkar
• 65,850 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
• 27,620 points
31 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
• 16,450 points
30 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,040 points
31 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
• 27,620 points
30 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
65 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
• 65,850 points
29 views
0 votes
2 answers
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
• 16,450 points

edited Aug 10, 2018 by Omkar 354 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
• 65,850 points
102 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
• 65,850 points
18 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.