hkjaaaip
hkjaaaip

Reputation: 123

How to interact with my smart contract on web browser

I deployed my contract on ropsten.
And I tried to interact with it on browser but error message said that it is not a function.
I already tried at NodeJS and there was no error. So the contract address or ABI file isn't wrong.

This is my code. Is there an error here?

const address = 'Contract addresss';
const myContract = new web3.eth.Contract(ABI, address);
let result = await myContract.methods.createDoc('asdf').call();
console.log(result);

Upvotes: 1

Views: 477

Answers (1)

Ming
Ming

Reputation: 775

Try changing this line

let result = await myContract.methods.createDoc('asdf').call();

To either one of these:

let result = await myContract.methods.createDoc().call('asdf');

let result = await myContract.methods.createDoc('asdf');

Upvotes: 2

Related Questions