0

Solidity function:

function abc(address x, address y, address z) external payable returns (uint256 x) {
    // something
}

In web3.py (python), I have called it successfully after deploying using following code:

w3.eth.call({
    'value':1*10**18,
    'gas':200000,
    'gasPrice':25*10**9,
    'to':contract_address,
    'from':myaddress,
    'data':data
})

data is created by combining the addresses appropriately.

I tried the following in truffle:

ex = await Example.deployed()
ex.abc('0x...', '0x...', '0x...').call({'from':'0x...', 'to':'0x...', 'value':1*10**18,'gas':200000, 'gasPrice':20})

I'm getting error: Uncaught TypeError: ex.abc(...).call is not a function

But when I run ex.abc, I get below output:

[Function (anonymous)] {
  call: [Function (anonymous)],
  sendTransaction: [Function (anonymous)],
  estimateGas: [Function (anonymous)],
  request: [Function (anonymous)]
}

So, how do I call this function in truffle?

1 Answer 1

0

ex.abc().call() requires ex.abc() to return a function which isn't the case. It should be ex.abc.call(parameters, {'from':...}).

Working code:

ex.abc.call('0x...', '0x...', '0x...', {'from':'0x...', 'to':'0x...', 'value':1*10**18,'gas':200000, 'gasPrice':20})

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.