iost 私有链搭建与学习

problem

account not exist

iwallet account create qyvlik --server localhost:30002 -a admin
Connecting to server localhost:30002 ...
ERROR: account not exist

在指定 admin 创建账户时,提示 account not exist,一般是指 admin 不在 iwallet 中,请确保执行了如下命令:

iwallet account import admin 2yquS3ySrGWPEKywCPzX4RTJugqRh7kJSo5aehsLYPEWkUxBWA39oMrZ7ZxuM4fgyXYs2cPwh5n8aNNpH5x2VyK1

expiration should be in (0, 90]

iwallet \--expiration 10000 --gas_limit 1000000 --gas_ratio 1 \--server localhost:30002 \--account admin \--amount_limit '*:unlimited' \publish helloworld.js helloworld.abi
ERROR: expiration should be in (0, 90]

iost 官方的部署合约例子中,expiration10000,但是执行后报 expiration should be in (0, 90]expiration 的取值是从 190,指定为 --expiration 90 即可,修复的命令如下:

iwallet \--expiration 90 --gas_limit 1000000 --gas_ratio 1 \--server localhost:30002 \--account admin \--amount_limit '*:unlimited' \publish helloworld.js helloworld.abi

prepare contract: contract iost.gas not found

iost 官方文档给的质押合约是错误的,gas.iost 才是正确的合约

iwallet --server 127.0.0.1:30002 --account admin call 'gas.iost' 'pledge' '["admin","qyvlik","100"]'

使用 iwallet compile 生成 abi 文件

iwallet compile example.js

生成的 abi 文件是 example.js.abi

使用合约转账

使用合约进行资金操作时,需要在 abi 文件中,每个导出的函数都有一个 amountLimit,如果 函数涉及到了资金操作,需要在 amountLimit 字段添加 [{ "token":"iost", "val":"100" }],其中 token 是资金操作的币种,val 是最多可以操作的金额,可以设置成 unlimited,合约以及 abi 参考如下:

class TestTransfer {init() {}can_update(data) {return blockchain.requireAuth(blockchain.contractOwner(), "active");}send(amount, to) {blockchain.transfer(tx.publisher, to, amount, "");}
};
module.exports = TestTransfer;
{"lang": "javascript","version": "1.0.0","abi": [{"name": "can_update","args": ["string"],"amountLimit": [],"description": ""},{"name": "send","args": ["string","string"],"amountLimit": [ {"token": "iost","val": "100"}],"description": ""}]
}

IOSTCrypto.sha3

IOSTCrypto.sha3 内部使用的是 sha256,返回的结果是 base58 编码

转账提示 VerifyError publisher error

转账的 memo 带有中文,提示 VerifyError publisher error,例如:

{"code":2,"message":"VerifyError publisher error"}

请更新官方 iost-official/java-sdk 到版本 3.0.6,或者使用非官方的 maven 依赖qyvlik/io.iost-java-sdk:

<dependency><groupId>io.github.qyvlik</groupId><artifactId>io.iost-java-sdk</artifactId><version>broker-v3.0.6</version>
</dependency>

使用谷歌浏览器插件 iwallet 报 TimeError

error: {"code":2,"message":"TimeError"}

iost 对应的报错代码 tx_pool.go#L258。

解决方式是

  1. 备份好私钥后
  2. 退出谷歌浏览器
  3. 卸载谷歌浏览器的 iwallet 插件
  4. 然后重新安装 iwallet 插件
  5. 再重新导入私钥

invalid contract version

iost 测试链节点报 invalid contract version,具体报错如下:

Error 2019-04-09 01:56:27.855 abi.go:81 invalid contract version: token.iost 1.0.3, please check `Monitor.prepareContract`
Warn 2019-04-09 01:56:27.855 isolator.go:246 isolator run action Action{Contract: system.iost, ActionName: updateNativeCode, Data: ["token.iost","1.0.3",""]}failed, status &{4 running action Action{Contract: system.iost, ActionName: updateNativeCode, Data: ["token.iost","1.0.3",""]}error: invalid contractID or version}, will rollback
Error 2019-04-09 01:56:27.856 pob.go:358 verify block failed, blockNum:8114577, blockHash:2oiwCLHGjfW8yTCBNz3WmHV6ZsaQiYkVZAHXZsEtd9iF. err=receipt not match, status not same: &{0 } != &{4 running action Action{Contract: system.iost, ActionName: updateNativeCode, Data: ["token.iost","1.0.3",""]}error: invalid contractID or version}
txHash:"s\267\313&\245\007\224\003s\004\253l\022\364W2\".\327\026\254\335-vb\341w\"\332\004\256\204" gasUsage:456900 status:<> returns:"[]"
txHash:"s\267\313&\245\007\224\003s\004\253l\022\364W2\".\327\026\254\335-vb\341w\"\332\004\256\204" gasUsage:357000 status:<code:4 message:"running action Action{Contract: system.iost, ActionName: updateNativeCode, Data: [\"token.iost\",\"1.0.3\",\"\"]}\n error: invalid contractID or version" >
Warn 2019-04-09 01:56:27.856 pob.go:181 received sync block error, err:receipt not match, status not same: &{0 } != &{4 running action Action{Contract: system.iost, ActionName: updateNativeCode, Data: ["token.iost","1.0.3",""]}error: invalid contractID or version}
txHash:"s\267\313&\245\007\224\003s\004\253l\022\364W2\".\327\026\254\335-vb\341w\"\332\004\256\204" gasUsage:456900 status:<> returns:"[]"
txHash:"s\267\313&\245\007\224\003s\004\253l\022\364W2\".\327\026\254\335-vb\341w\"\332\004\256\204" gasUsage:357000 status:<code:4 message:"running action Action{Contract: system.iost, ActionName: updateNativeCode, Data: [\"token.iost\",\"1.0.3\",\"\"]}\n error: invalid contractID or version" >
Info 2019-04-09 01:56:29.022 sync.go:158 Syncing block in [8114555 8115554]...
Info 2019-04-09 01:56:31.067 sync.go:158 Syncing block in [8114555 8115554]...

问题原因是 iost-node 版本比较低。解决方式是,升级 iost-node。

execution kill

iost-node 同步区块日志报 execution kill,可能原因是磁盘不是 SSD 或者 CPU 频率比较低,升级磁盘到 SSD 或者 CPU 规格。

参考

  • iWallet.html
  • install-golang
  • LocalServer.html

iost 私有链搭建与学习相关推荐

  1. 以太坊 私有链搭建 Geth+Mist钱包

    近期在区块链的热潮推动下,我开始研究区块链技术,尤其是智能合约.可编程式的智能合约龙头老大非以太坊莫属了,其他的合约平台如 hyperledger,EOS 相对来说没以太坊成熟,以后陆续在研究.好了, ...

  2. 以太坊学习路线——(一)私有链搭建与基本操作

    这篇博客演示的基本操作系统环境是CentOS 7,参考书籍:以太坊开发实战--以太坊关键技术与案例分析 第五章(吴寿鹤.冯翔.刘涛.周广益   著). 文章结构: 一.geth客户端安装 二.搭建一个 ...

  3. 以太坊学习笔记(一):基于POA的私有链搭建

    简介 这里以太坊的一些特性就不赘述,可以在官网进行查阅:https://www.ethereum.org/. 下面主要介绍基于POA机制的环境的搭建来窥探以太坊的运行机制. 源码下载及编译 1.git ...

  4. docker 搭建以太坊私有链搭建

    最近区块链,火得不行,身边也有朋友准备玩这个,说是搭了一个星期,没有把环境搭建起来,叫我帮忙看看环境怎么搭建 于是我找到了官方的地址 https://github.com/ethereum/go-et ...

  5. 如何在geth中创建genesis.json_基于以太坊的私有链搭建,mist+geth实现

    以前让学生做毕业设计,今天有人问起来,就写一个小教程,说一说基于eth的私有链如何搭建.非常简单. 一.geth,mist 客户端下载 1.这里我给大家介绍下,以太坊客户端,以太坊客户端主要分成两类. ...

  6. Ubuntu下USDT私有链搭建

    本文作者:陈进坚 个人博客:https://jian1098.github.io CSDN博客:https://blog.csdn.net/c_jian 简书:https://www.jianshu. ...

  7. Etherum私有链搭建

  8. 搭建以太坊私有链(PoA)--CentOS7.6 on 阿里云ECS、macOS Catalina on Mac、Ubuntu20.04 on Raspberry Pi 4B

    使用Geth搭建以太坊PoA私有链 搭建以太坊私有链(PoA) 1 阿里云ECS上的操作步骤 1.1 准备环境 1.2 安装Geth及Tools 1.3 创建以太坊私有链的数据文件夹 1.4 用pup ...

  9. Linux环境下搭建区块链私有链+部署智能合约

    文章目录 一.前期准备 二.安装goland环境 三.安装go版本的以太坊源码,并编译 四.私有链搭建 五.私有链节点加入 六.部署智能合约 七.参考链接 一.前期准备 安装更新相关组件 sudo y ...

最新文章

  1. Linux其实非常好学
  2. A级计算机考试试题,计算机等级考试一级试题及答案-计算机a级试题
  3. 计算机组成原理第二章数据,计算机组成原理第二章数据表示(含答案)
  4. QT的QListIterator类的使用
  5. 数据库:SQL 窗口函数知识介绍
  6. 【收集】C#一些基础的面试题
  7. Vue中动态(import 、require)显示img图片
  8. Android横向滚动卡片,Android实现横向滑动卡片效果
  9. Linux(Ubuntu)使用日记------ssh远程登录腾讯云
  10. 【GPS模组】移远EC20 基于Arduino的GPS流速仪
  11. php漫画源码,小涴熊漫画CMS:开源的PHP漫画源码
  12. MAC 下MySQL常用命令
  13. Originpro使用技巧
  14. tomcat6到tomcat9解压版(64位)随意下载
  15. PROFINET的时钟同步(一)
  16. 创建AWS VPC Peering
  17. 刽子手游戏 做题笔记
  18. windows下使用命令行禁用笔记本自带键盘
  19. 推送流程(极光推送)
  20. 写一个搜索引擎系统(Java版)

热门文章

  1. android 中 虚拟键盘
  2. 逻辑与和逻辑或,比较
  3. JAVA面经复习(二十六)面试难度:☆☆☆☆
  4. 微信公众号怎么生成带参数的二维码?
  5. matlab对矩阵自相关,自相关矩阵和互相关矩阵的matlab实现
  6. 【论文阅读】Entity Structure Within and Throughout: Modeling Mention Dependencies for Document-Level Relat
  7. 「Feign-Http」 Feign请求http接口
  8. SpringBoot配置Mybatis多数据源
  9. commvault备份mysql_CommVault备份到华为云对象存储实践
  10. redis--memcached