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

Words
220
Reading
1 min
Listen
Play
9y

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 CMakeClang
             - LinuxOpenSSLLLVM 4.0
             -  secp256k1-zkp, PGP
             -  WASMJavascript
     - Telegram EOS Developer
          -  EOS 
     -  EOS  pseudo-distributed
     -  EOS 
     -  EOS
     -  
              - graphene()SteemitBitShares
              - PressOneBigOne
              - OracleChain
              - Motion.one
              - HMS(Health Mutual Society)
EOS之路 第三篇 编写智能合约 | Ecency