Truffle Smart Contract Error: Invalid number of parameter
I followed the tutorial of quorum with truffle: https://truffleframework.com/tutorials/building-dapps-for-quorum-private-enterprise-blockchains
Now I want to migrate the SimpleStorage.sol Smart Contract to the blockchain, but I want to make it to add the "PrivateFor" parameter.
This is my Smart Contract:
pragma solidity ^0.4.17;
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;
}
}
This is my: 2_deploy_simplestorage.js
var SimpleStorage = artifacts.require("SimpleStorage");
module.exports = function(deployer) {
deployer.deploy(SimpleStorage, 42, {privateFor: ["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]})
};
But when I do truffle migrate, I get this error:
$ truffle migrate
⚠️ Important ⚠️
If you're using an HDWalletProvider, it must be Web3 1.0 enabled or your migration will hang.
Starting migrations...
======================
> Network name: 'development'
> Network id: 10
> Block gas limit: 3758096384
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0x0a55cd010bb30247c3ae303e54be8dd13177b520af5967728cf77e07ca9efe76
- Blocks: 0 Seconds: 0
> Blocks: 0 Seconds: 0
> contract address: 0x1932c48b2bF8102Ba33B4A6B545C32236e342f34
> account: 0xed9d02e382b34818e88B88a309c7fe71E65f419d
> balance: 1000000000
> gas used: 245462
> gas price: 0 gwei
> value sent: 0 ETH
> total cost: 0 ETH
- Saving migration to chain.
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0 ETH
2_deploy_simplestorage.js
=========================
Deploying 'SimpleStorage'
-------------------------
Error: *** Deployment Failed ***
"SimpleStorage" -- Invalid number of parameters for "undefined". Got 2 expected 1!.
at C:\Users\dany.vandermeij\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-deployer\src\deployment.js:364:1
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Truffle v5.0.1 (core: 5.0.1)
Node v8.11.4
When I don't add the "privateFor" parameter, it works:
var SimpleStorage = artifacts.require("SimpleStorage");
module.exports = function(deployer) {
deployer.deploy(SimpleStorage, 42)
};
But I need this privateFor parameter..
Does someone know how to fix this?

Hey @BlockChainProgrammer. Thanks for guiding me on how to use the Quorum proxy. It worked.
For this error, Try to upgrade/downgrade your truffle version to v4.1.
$ npm install -g truffle@4.1.10
and change the version of solidity to 0.4.24 in your truffle-config.js
and the SimpleStorage.sol
and add back privateFor in your migration file.
- Thanks mate. I will check it out in a few hours – BlockchainProgrammer Jan 24 at 7:34
- Hello, so you mean in SimpleStorage.sol this:
pragma solidity ^4.1.24;
and in the truffle-config.js file this:solc: { version: "4.1.24", }
? Because I get an error – BlockchainProgrammer Jan 24 at 7:45 - That's right. In both of them you need the same version. It worked for me. – exploringsincebirth Jan 24 at 7:52
- Also try to join this slack group, from the quorum website. – exploringsincebirth Jan 24 at 8:07
- Hello, I get this error:
SyntaxError: Source file requires different compiler version (current compiler is 0.4.24+commit.e67f0147.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma solidity ^4.1.24;
– BlockchainProgrammer Jan 24 at 8:12
Problem solved!
What I had to do is to downgrade truffle to "4.1.10" with:
truffle uninstall -g
and then
npm install -g truffle@4.1.10
Truffle Smart Contract Error: Invalid number of parameter的更多相关文章
- smart contract 知识点
知识点 memory vs storage vs stack storage , where all the contract state variables reside. Every contra ...
- nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
iwangzheng.com tty:[0] jobs:[0] cwd:[/opt/nginx/conf] 12:45 [root@a02.cmsapi]$ /usr/local/nginx/sbin ...
- nginx重启报错:nginx: [error] invalid PID number "" in "/run/nginx.pid"
问题描述:执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number “” in “/run/ngin ...
- nginx: [error] invalid PID number “” in “/usr/local/var/run/nginx/nginx.pid”
在Mac上用brew安装Nginx,然后修改Nginx配置文件,再重启时报出如下错误: nginx: [error] invalid PID number "" in " ...
- nginx: [error] invalid PID number "" in "/run/nginx.pid"
在重启云主机(系统)之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number “” in “/ ...
- Centos7.5中Nginx报错:nginx: [error] invalid PID number "" in "/run/nginx.pid" 解决方法
服务器重启之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number "" ...
- [nginx报错问题]reload时报错:nginx: [error] invalid PID number "" in ...
错误 第一次探索nginx,执行以下命令时: nginx -s reload 报出错误: nginx: [error] invalid PID number "" in ... * ...
- 解决 nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
使用/usr/local/nginx/sbin/nginx -s reload 重新读取配置文件出错 [root@localhost nginx]/usr/local/nginx/sbin/nginx ...
- Using APIs in Your Ethereum Smart Contract with Oraclize
Homepage Coinmonks HOMEFILTER ▼BLOCKCHAIN TUTORIALSCRYPTO ECONOMYTOP READSCONTRIBUTEFORUM & JOBS ...
随机推荐
- 关于cubic-bezier 贝塞尔曲线的简单了解
在animation和transition两个属性中,cubic-bezier是控制变化的速度曲线,主要是生成速度曲线的函数 规定用法是: cubic-bezier(<x1>,<y1 ...
- K2 BPM_北汽新能源业务流程管理信息系统建设思考_全球领先的工作流引擎
本文由CIO发展中心根据北汽新能源流程与IT总监刘伟霞在“亦庄CIO数字化转型探索——CIO发展中心亦庄分舵2019夏季论坛”活动中演讲整理. 在“亦庄CIO数字化转型探索——CIO发展中心亦庄分舵2 ...
- iOS分类(category),类扩展(extension)—史上最全攻略
背景: 在大型项目,企业级开发中多人同时维护同一个类,此时程序员A因为某项需求只想给当前类currentClass添加一个方法newMethod,那该怎么办呢? 最简单粗暴的方式是把newMethod ...
- OpenCV 图象腐蚀形态学操作 全家桶
图象腐蚀与形态学操作 opencv 1. 通过调用库函数实现图像的腐蚀.膨胀: 2. 通过设置结构元素.元素大小.形态学操作类型实现对图象的形态学操作. 源码(VS2017+OpenCV 4.0) # ...
- Python之定义默认参数
定义函数的时候,还可以有默认参数. 例如Python自带的 int() 函数,其实就有两个参数,我们既可以传一个参数,又可以传两个参数: >>> int('123') 123 > ...
- JAVA 泛型 通配符? extends super限定,实例区分extends super限定的作用用法
java泛型中的关键字 ? 表示通配符类型 <? extends T> 既然是extends,就是表示泛型参数类型的上界,说明参数的类型应该是T或者T的子类. <? super T& ...
- We're sorry but mobile doesn't work properly without JavaScript enabled. Please enable it to continue.
vue过程中遇见这个问题:We're sorry but mobile doesn't work properly without JavaScript enabled. Please enable ...
- Java基础 与时间日期相关的类:System -Date -SimpleDateFormat -Calendar类 -解决后缀.000Z 的时区问题
笔记总结: /**与时间相关的类:System_Date_SimpleDateFormat_Calendar类 * 1.system 类下的currentTimeMillis() * 输出从1970年 ...
- Vue -- element-ui FileSaver.js 导出
html <el-button type="danger" @click="exportRs">导出Excel报表</el-button> ...
- git 在eclipse中忽略上传文件
在我们的工程项目中,有些文件是不需要上传到服务器上的,比如那些 */target/ */bin/*.settings/*.classpath*.gitignore*.project 我们将这些文件添加 ...