I'm trying to use web3.js with infura.io to interact with my smartcontract. here is my simple greeter contract code
pragma solidity ^0.5.7;
contract greeter{
string greeting;
function greet(string memory _greeting)public {
greeting=_greeting;
}
function getGreeting() public view returns(string memory) {
return greeting;
}
}
Here is what I found from web3.js documentation.
var tx = web3.eth.sendTransaction({
from: '0x3dCDe57Ad49d639c4D702b607Dd5eBc0aB54A671',
nonce: web3.toHex(txCount),
gasLimit: web3.toHex(1000000),
gasPrice: web3.toHex(web3.toWei('10', 'gwei')),
data:0x756774689538938966626728299293638893o
});
web3.eth.accounts.signTransaction(tx, privateKey [, callback]);
But it doesn't take me anywhere. Because,where can I pass greeting data? All the documentation talks about sending ether. Then what about sending string data like this? with web3.js 0.20 I can read greeting from chain. I wanted to add new greeting string with greet function. but somehow I have no idea about signing transaction. could anyone help me in understanding how to sign transacion and adding greeting to the contract using web3.js?