我正在尝试部署智能合约:
`
实用性>> 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''
有人知道如何处理该问题吗?
答案 0 :(得分:1)
松露最近才增加了对法定私人交易的支持。因此,您需要Truffle 5.0.14版。 希望对您有所帮助。