Hyperledger burrow集成truffle

环境

os:centos7.6

1. 安装nodejs和npm

安装nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm 
 nvm --version

使用nvm安装node和npm

nvm install node
node --version
npm --version

安装开发工具

sudo yum install gcc-c++ make

2. 安装solc

参考:https://blog.csdn.net/kk3909/article/details/105381559

3. 安装truffle

npm install truffle -g

报错?

Error: EACCES: permission denied, open '/root/.config/truffle/config.json'
You don't have access to this file

再安装一次

npm install truffle -g --unsafe-perm

4. 使用truffle部署智能合约

4.1 创建项目
mkdir MetaCoin
cd MetaCoin
truffle unbox metacoin
4.2 修改config
cat truffle-config.js
module.exports = {
  networks: {
    burrow: {
      host: "localhost",
      port: 26860,
      network_id: "*"
   }
  }
};
4.3 编译
truffle  compile
4.4 测试
truffle  test
4.5 部署
 truffle  deploy --network burrow

报错?

Error: Expected parameter 'from' not passed to function.
    at /root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/expect/index.js:5:1
    at Array.forEach (<anonymous>)
    at Object.options (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/expect/index.js:3:1)
    at Object.fork (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/environment/environment.js:30:1)
    at setupDryRunEnvironmentThenRunMigrations (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:225:1)
    at /root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:207:1
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

看起来是缺少from参数,修改一下truffle-config.js,from为节点的创世地址。

module.exports = {
  networks: {
    burrow: {
      host: "localhost",
      port: 26860,
      from: "7E4F21487B2E2CB2F6DE9AEA1875BD1FC55114CE",
      network_id: "*"
   }
  }
};
Error:  *** Deployment Failed ***

"Migrations" -- sender account not recognized.

    at /root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Migration._deploy (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:70:1)
    at Migration._load (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:57:1)
    at Migration.run (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:167:1)
    at Object.runMigrations (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:148:1)
    at Object.runFrom (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.run (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:87:1)
    at runMigrations (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:253:1)
    at setupDryRunEnvironmentThenRunMigrations (/root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:241:1)
    at /root/.nvm/versions/node/v13.12.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:207:1

还是出错,通过web3.eth.accounts是查询不到任何账户的,问题应该在这。

web3不支持ed25519类型的地址,我们重新生成账户,再测试。

./burrow spec -v1 -d1 |./burrow configure -s-  --curve-type secp256k1 >burrow.toml

这时通过web3.eth.accounts可以查询到账户,再部署一遍
还是报错?

Error:  *** Deployment Failed ***

"Migrations" -- Returned error: account not found at address 0xbdb18dda8da1bfc0123143674f86d8ca506c9ffa.

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:70:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:57:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:167:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:148:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:87:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:253:1)
    at setupDryRunEnvironmentThenRunMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:241:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:207:1

经查询根本没有这个账户0xbdb18dda8da1bfc0123143674f86d8ca506c9ffa,从哪来??

发现都是dry-run时报错,最终解决方案:

 truffle  deploy --network burrow --skip-dry-run

可以部署、调用合约,但通过grpc 不能获取合约metadata数据

结论

burrow暂时还不完全兼容truffle

参考文献

https://linuxize.com/post/how-to-install-node-js-on-centos-7/
https://www.trufflesuite.com/docs/truffle/getting-started/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值