小编Oci*_*rne的帖子

部署智能合约时“未定义”的参数数量无效

我正在尝试在 testRPC 上部署我的第一个投票合约,下面是我的代码..出于某种原因,当我开始部署时它会抱怨。

错误似乎来自 arguments 参数。我尝试传递一个空数组,它说“得到 0 预期 1!”。我试着只传递一个名字,它说“value.forEach”不是一个函数。

Web3 = require('web3')
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
sourceCode = fs.readFileSync('Voting.sol').toString()
solc = require('solc')
compiledCode = solc.compile(sourceCode)
abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface)
VotingContract = new web3.eth.Contract(abiDefinition)
byteCode = compiledCode.contracts[':Voting'].bytecode

VotingContract.deploy({
    data: byteCode, 
    arguments:['Joseph','Sean','Matthew']
}).send({
    from: '0x00D1AE0A6fC13B9ecdefA118B94cF95ac16D4ab0', 
    gas: 4700000
})
.on('error', function(error) {
    console.log(error);
}
.then(function(newContractInstance) {
    console.log(newContractInstance.options.address)
}
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激。谢谢你。

node.js ethereum solidity web3js web3-donotuse

1
推荐指数
1
解决办法
5274
查看次数

标签 统计

ethereum ×1

node.js ×1

solidity ×1

web3-donotuse ×1

web3js ×1