Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- throw errors.InvalidResponse(result);
- ^
- Error: The method eth_sendTransaction does not exist/is not available
- const contractFunction = contract.greet({from:web3.eth.defaultAccount},"hello all devs");
- const functionAbi = contractFunction.encodeABI();
- let estimatedGas;
- let nonce;
- console.log("Getting gas estimate");
- contractFunction.estimateGas({from: account}).then((gasAmount) => {
- estimatedGas = gasAmount.toString(16);
- console.log("Estimated gas: " + estimatedGas);
- web3.eth.getTransactionCount(account).then(_nonce => {
- nonce = _nonce.toString(16);
- console.log("Nonce: " + nonce);
- const txParams = {
- gasPrice: '0x09184e72a000',
- gasLimit: 3000000,
- to: contract_Address,
- data: functionAbi,
- from: account,
- nonce: '0x' + nonce
- };
- const tx = new Tx(txParams);
- signed_tx = web3.eth.account.signTransaction(tx, privateKey)
- tx_hash= web3.eth.sendRawTransaction(signed_tx.rawTransaction)
- tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
- //tx.sign(privateKey);
- console.log(tx_receipt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement