When I write the line "const cdata = await contractInstance.methods.setName("Raj").encodeABI;" in my code, I get the error "SyntaxError: await is only valid in async function".
I understand that you've used it in describe and it functions, but how do I go about doing this in plain JavaScript without using unnecessary mocha testing or something? Can someone please help? Thanks!

Mar 3, 2019, 6:36 PM
When I try your second method ^ :(
async function x(){
let cdata = await contractInstance.methods.setName("Raj").encodeABI;
const receipt = await web3.eth.sendTransaction({
from: userAddress,
to: contractInstance.address,
value: '0x0',
data: cdata
});

console.log(receipt);
let result = await contractInstance.methods.getName().call();
console.log(result);

}

x();
Here's the code snippet if someone would like to make changes to it..
Mar 3, 2019, 6:43 PM

© 2024 Draquery.com All rights reserved.