我正在尝试让已部署的 HelloWorld 合同在节点应用程序中运行。我想像这样运行该call()
函数来检查它:
const deployed = helloWorldContract.new({
from: acct1,
data: compiled.contracts[':HelloWorld'].bytecode,
gas: 151972,
gasPrice: 5
}, (error, contract) => {
if(!error){
console.log(contract.displayMessage.call());
} else {
console.log(error);
}
});
以下是供参考的合同:
contract HelloWorld {
function displayMessage() public constant returns (string){
return "hello from smart contract - {name}";
}
}
当我尝试console.log(contract.displayMessage.call())
回调时,它返回:TypeError: Cannot read property 'call' of undefined
,但是,当我登录它时,console.log(contract.displayMessage)
它返回:
{ [Function: bound ]
request: [Function: bound ],
call: [Function: bound ],
sendTransaction: [Function: bound ],
estimateGas: [Function: bound ],
getData: [Function: bound ],
'': [Circular] }
我在这里做错了什么?如何call
在已部署的合约中运行该功能?