This may be a very basic question, I don't know why but I am unable to find correct solution to how can I call my contract's method using sendTransaction
. I have a transfer(address, uint256)
function which I want to call using sendTransaction
and callTransaction
. I have my contract compiled and I have it's abi and address. Now, how can I call different metrhods of the contract using sendTransaction
?
I was reading the question Syntax for calling contract state changing methods, and I got explanations for function having single parameter but what if it has more than a parameter of different types, like here transfer()
function accepts 2 parameters.
[Ethereum] How to call the contract’s function using sendTransaction
contract-developmentweb3js
Best Answer
Posting solution to my own question for anyone who needs it. To call a contract function from
geth
:Note: You can add other fields in
sendTransaction
like value etcetera, I have skipped that for simplicity to new use users.To all the users who face challanges with signing data using private key. The pseudo code for signing and sending a transaction to contract using private key: