简体   繁体   English

如何在网络浏览器上与我的智能合约交互

[英]How to interact with my smart contract on web browser

I deployed my contract on ropsten.我在 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.我已经在 NodeJS 上试过了,没有错误。 So the contract address or ABI file isn't wrong.所以合约地址或者ABI文件没有错。

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);

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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM