我正在尝试部署智能合约:
`
pragma solidity >=0.4.21;
contract SimpleStorage {
uint public storedData;
constructor(uint initVal) public {
storedData = initVal;
}
function set(uint x) public {
storedData = x;
}
function get() view public returns (uint retVal) {
return storedData;
}
}`
我创建了 2_deploy.js
var SimpleStorage = artifacts.require("SimpleStorage");
module.exports = function(deployer) {
// Pass 42 to the contract as the first constructor parameter
deployer.deploy(SimpleStorage, 42, {privateFor:
["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]})
};
但是当我执行 truffle.migration 我得到这个错误:
'Error encountered, bailing. Network state unknown. Review
successful transactions manually.
Error: Invalid number of parameters for "undefined". Got 2
expected 1!
at Object.InvalidNumberOfParams
(/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-
contract/~/web3-core-helpers/src/errors.js:32:1)
at Object._createTxObject
(/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-
contract/src/index.js:699:1)
at Contract.deploy
(/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-
contract/src/index.js:504:1)
at Function.deploy
(/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-
contract/lib/execute.js:214:1)
at constructor.detectNetwork.then.network
(/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-
contract/lib/contract/constructorMethods.js:56:1)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Truffle v5.0.13 (core: 5.0.13)
Node v8.9.4''
有谁知道如何处理这个问题?