EOS之路 第三篇 编写智能合约

in cn •  8 years ago  (edited)

Creating a Contract,编写合约

实例合约

使用eosc 创建并发表货币合约,在eos/contracts/currency的文件夹中有实例的现金合约

###1. 为货币合约创立一个账户tester

$ ./eosc create key
$ ./eosc create key
$ ./eosc create account tester currency PublicKey1 PublicKey2

###2. 发布货币合约.wast到`abi(Application Binary Interface)

$ ./eosc contract currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi

###3. 发布之后把货币转移到相应的货币账户
转移到account tester

$ ./eosc push message currency transfer '{"from":"currency","to":"tester","quantity":50}' -s currency -s tester -p active@currency

目前(笔者写作时间为9月12日),块链还不能验证签名,所以任何人只要声明适当的权限就可以做任何事情。 在未来,当局将有能力指示使用哪些钥匙才能来签署交易的钱包。 此API的未来版本也可能会通过合同的试运行来自动检测范围和授权。
我们在转移一次50,讲tester的账户清零

$ ./eosc push message currency transfer '{"from":"currency","to":"tester","quantity":50}' -s currency -s tester -p active@currency

###4. 再次验证tester账户
tester 账户应该为0

$ ./eosc push message currency transfer '{"from":"tester","to":"inita","quantity":50}' -s inita -s tester -p tester@active

技术爱好者的知识星球会分享最及时的EOS 团队进展以及技术发展

本星球会分享:
     - EOS code 基础知识:
             - C++: boost, CMake,Clang,
             - Linux:OpenSSL,LLVM 4.0,
             - 安全加密: secp256k1-zkp, PGP
             - 前端: WASM,Javascript
     - 筛选并发布Telegram “EOS Developer”优质信息
          -  EOS 单机节点运行
     -  EOS 虚拟多节点运行 (pseudo-distributed)
     -  EOS 多节点运行
     -  EOS智能合约编写与发布
     - 优秀项目架构和设计原理: 
              - graphene(石墨烯),Steemit,BitShares
              - PressOne,BigOne
              - OracleChain
              - Motion.one
              - HMS(Health Mutual Society)
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

膜拜~~