智能合约:.methods.request()。send()不显示任何内容

问题描述 投票:0回答:1

我有以下问题:

我在混音上写了一份智能合约:

pragma solidity ^0.5.1;

contract anotherTry {

 function Hello() external pure returns (string memory) {
    return "Hello World !!!";
}


}

然后我编译了它然后我得到了它的WEB3DEPLOY数据并将它添加到我的Geth控制台中。我收到的合同地址和我使用它们的混音网站上的ABI就像这样:

//addr = the contract address received from the Geth console
//abit = obviously,the ABI
//account = a random & valid account address(I've tried with addr too...who knows maybe it could work)

let MyContract = new web3.eth.Contract(abi, addr);
MyContract.methods.Hello().send({ from: account }).then(receipt => { console.log("SUCCESS"); });

问题是我没有收到任何消息,但是当我尝试时,我收到了带有函数和东西的循环结构

console.log(MyContract.methods);

知道为什么我不能“连接”我的智能合约吗?我正在使用NodeJS和web3 1.0.0和Geth

node.js blockchain ethereum solidity smartcontracts
1个回答
0
投票

我解决了,

实际上是web3提供程序声明的一个问题,我应该调用methods.request()。call()而不是.send()

无论如何,谢谢你的帮助!

© www.soinside.com 2019 - 2024. All rights reserved.