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.
Contract Function Call – Using sendTransaction in Solidity
contract-developmentweb3js
Related Topic
- Solidity – Using sendTransaction When Calling a Contract Function
- Metamask Transactions – Send Tokens with Metamask and Custom Data Using sendTransaction
- Solidity – How to Override Inherited Contracts with Same Method Name but Different Signatures
- Solidity Contract Development – How Does the Function Call Work?
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: