0

Firstly I know this has been asked before, but I have became confused with so many different formats and the move to 1.0. Many online resources do not make it clear about the version and I have become confused.

I have the code below from the docs.


app.post("/api/addEmail", function(req, res) {
   var email = req.body.emailAddress;
   var wallet = req.body.walletAddress; // new wallet for user
   var emailHash = web3js.utils.sha3(email);
   console.log(email);
   console.log(wallet);
   console.log(emailHash);

contract.methods.addEmail(wallet, emailHash).send({from: owner})
.on('transactionHash', (hash) => {
    console.log(hash);
})
.on('receipt', (receipt) => {
    console.log(receipt);
})
.on('confirmation', (confirmationNumber, receipt) => {
    console.log(confirmation);
    console.log(receipt);
})
.on('error', console.error);

});

I cannot really understand where to sign it, and I get the following -

Error: Node error: {"code":-32601,"message":"The method eth_sendTransaction does not exist/is not available"}
    at Function.validate (/home/trevor/api/node_modules/web3-providers/dist/web3-providers.cjs.js:114:18)
    at HttpProvider._callee$ (/home/trevor/api/node_modules/web3-providers/dist/web3-providers.cjs.js:710:61)
    at tryCatch (/home/trevor/api/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/home/trevor/api/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as next] (/home/trevor/api/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/home/trevor/api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/home/trevor/api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at process._tickCallback (internal/process/next_tick.js:68:7) false 0

Has anyone a code example for web 1.0 and nodejs?

  • Which provider (blockchain node) are you using ? – Laxmana May 25 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.