5

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?

1
  • What is the full error message you get?
    – Ismael
    Commented Sep 30, 2017 at 15:34

2 Answers 2

9

You can call the method directly as follows without sendTransaction:

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

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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.