0

Here's my contract code:

pragma solidity 0.8.9;

contract hodl {

  event printNum(uint num);
  event printValue(uint val);

  function deposit(uint number) payable public {
    emit printNum(number);
    emit printValue(msg.value);
  }
    
}

Here's what I'm doing in truffle console:

truffle(ganache)> c = await hodl.deployed()
undefined
truffle(ganache)> c.deposit(420).sendTransaction({from: web3.eth.accounts[0], value: 10000000000000000000})
evalmachine.<anonymous>:0
c.deposit(420).sendTransaction({from: web3.eth.accounts[0], value: 10000000000000000000})
               ^

Uncaught TypeError: c.deposit(...).sendTransaction is not a function

Any ideas?

1 Answer 1

0

This is how you can call payable contract method along with some ether and sender.

c.deposit(420, { value: 10000000000000000000, from: web3.eth.accounts[0]})
0

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.