2

I want to send 100wei to a payable function in my deployed contract. But i don't want to sign the transaction because of to much effort to get this going. I just want to submit the transaction with metamask. Therefore i need the correct web3 command to call my 'depositFunds' method and send 100 wei. Currently i have this command, but i get frankly an error. myContractInstance.depositFunds().sendTransaction({from: web3.eth.accounts[0], gas: 3000000, value: 100}, function(err, res){});

What do i have to change to get this going?

  • What is the full error message you get? – Ismael Sep 30 '17 at 15:34
5

You can call the method directly as follows without sendTransaction:

myContractInstance.depositFunds({from: web3.eth.accounts[0], gas: 3000000, value: 100}, function(err, res){});
1

Here's a tutorial I wrote on interacting with smart contracts using MetaMask. Calling a payable function is the same as this, just add a value to the transaction:

https://medium.com/metamask/calling-a-smart-contract-with-a-button-d278b1e76705

You'll need the contract address and its ABI to call a method.

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.