Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. throw errors.InvalidResponse(result);
  2. ^
  3.  
  4. Error: The method eth_sendTransaction does not exist/is not available
  5.  
  6. const contractFunction = contract.greet({from:web3.eth.defaultAccount},"hello all devs");
  7.  
  8. const functionAbi = contractFunction.encodeABI();
  9.  
  10. let estimatedGas;
  11. let nonce;
  12.  
  13. console.log("Getting gas estimate");
  14.  
  15. contractFunction.estimateGas({from: account}).then((gasAmount) => {
  16. estimatedGas = gasAmount.toString(16);
  17.  
  18. console.log("Estimated gas: " + estimatedGas);
  19.  
  20. web3.eth.getTransactionCount(account).then(_nonce => {
  21. nonce = _nonce.toString(16);
  22.  
  23. console.log("Nonce: " + nonce);
  24. const txParams = {
  25. gasPrice: '0x09184e72a000',
  26. gasLimit: 3000000,
  27. to: contract_Address,
  28. data: functionAbi,
  29. from: account,
  30. nonce: '0x' + nonce
  31. };
  32. const tx = new Tx(txParams);
  33. signed_tx = web3.eth.account.signTransaction(tx, privateKey)
  34. tx_hash= web3.eth.sendRawTransaction(signed_tx.rawTransaction)
  35. tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
  36. //tx.sign(privateKey);
  37. console.log(tx_receipt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement