我想将一些ETH发送到智能合约地址
Test.deployed().then(function(instance) {return instance.contribute("0x1e0c326f4f24b5e9f5d42d695f48983d0a72b240", {from:web3.eth.accounts[0],value:10});})
但我总是得到
truffle(development)> Test.deployed().then(function(instance) {return instance.contribute("0x1e0c326f4f24b5e9f5d42d695f48983d0a72b240", {from:web3.eth.accounts[0],value:10});})
TypeError: instance.contribute is not a function
at evalmachine.<anonymous>:1:61
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
truffle(development)> truffle(development)>
我使用的是松露的最新版本,所以版本4.x
与
相同的问题Test.deployed().then(function(instance) {return instance.getElements.call();})
更新
contract MyContract Common {
function setMultisigWallet(address newMultisigWallet) public onlyOwner {
multisigWallet = newMultisigWallet;
}
function() external payable {
executeSale();
}
}
答案 0 :(得分:0)
通过instance.sendTransaction()
将交易直接发送到合同。像所有可用的合约实例函数一样,它的用法也一样,并且具有与web3.eth.sendTransaction相同的API,但没有回调。如果未指定,to
值将自动为您填充。