简体   繁体   English

使用web3.js的“发送”有什么问题?

[英]What is the problem in use of “send” of web3.js?

I'm trying to use web3.js (v1.0.0) in order to send a transaction to smart contract, so i use send() method of the contract. 我正在尝试使用web3.js(v1.0.0)来向智能合约发送交易,因此我使用了合约的send()方法。 My code: 我的代码:

let contract = new icoWeb3.eth.Contract(getABI(), contractAddress);

contract.methods.myMethod().send({
    from: from,
    value: value
});

The problem is that contract.methods.myMethod equals "undefined". 问题是contract.methods.myMethod等于“ undefined”。 So i can't utilize send() method to do what i need. 所以我不能利用send()方法来做我需要的事情。 Docs example code: 文件范例程式码:

myContract.methods.myMethod([param1[, param2[, ...]]]).send(options[, callback])

What do i need to do in order to make method send() work? 为了使方法send()正常工作,我需要做什么? Thanks and i hope for your help... 谢谢,我希望您的帮助...

If you are using send, you are calling a setter method of your contract. 如果使用send,则调用合同的setter方法。

So, you should provide some arguments: 因此,您应该提供一些参数:

 MyMethod(args1 [, args2, ...])

Can you provide the method of your solidity contract? 您能提供您的固定合同的方法吗?

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

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