3 Star 12 Fork 5

Bytom Blockchain / equity

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

equity compiler tool

The equity compiler tool is the equity commandline compiler.

Requirements

Go version 1.8 or higher, with $GOPATH set to your preferred directory

Build source code, the build target of the equity compiler commandline tool is equity.

$ make equity

then change directory to equity, and you can find the commandline tool equity :

$ cd equity

Usage on the commandline

Usage of equity commandline compiler:

$ ./equity <input_file> [flags]

Using help provides you with an explanation of all options.

$ ./equity --help

available flags:

    --bin        Binary of the contracts in hex.
    --instance   Object of the Instantiated contracts.
    --shift      Function shift of the contracts.

Example

The contents of the contract file TradeOffer(without file suffix restrictions) are as follows:

contract TradeOffer(assetRequested: Asset,
                    amountRequested: Amount,
                    seller: Program,
                    cancelKey: PublicKey) locks valueAmount of valueAsset {
  clause trade() {
    lock amountRequested of assetRequested with seller
    unlock valueAmount of valueAsset
  }
  clause cancel(sellerSig: Signature) {
    verify checkTxSig(cancelKey, sellerSig)
    unlock valueAmount of valueAsset
  }
}
  • Compiler contract file to generate the binary:
./equity TradeOffer --bin

the return result:

======= TradeOffer =======
Binary:
547a6413000000007b7b51547ac1631a000000547a547aae7cac
  • Query the clause shift for contract:
./equity TradeOffer --shift

the return result:

======= TradeOffer =======
Clause shift:
    trade:  00000000
    cancel:  13000000
    ending:  1a000000

NOTE: If the contract contains only one clause, Users don't need clause selector when unlock contract. Furthermore, there is no signification for ending clause shift except for display.

  • Instantiated contract with arguments:
./equity TradeOffer --instance 84fe51a7739e8e2fe28e7042bb114fd6d6abd09cd22af867729ea001c87cd550 1000 0014d6598ab7dce6b04d43f31ad6eed76b18da553e94 7975f3f71ca7f55ecdef53ccf44224d514bc584bc065770bba8dcdb9d7f9ae6c

the return result:

======= TradeOffer =======
Instantiated program:
207975f3f71ca7f55ecdef53ccf44224d514bc584bc065770bba8dcdb9d7f9ae6c160014d6598ab7dce6b04d43f31ad6eed76b18da553e9402e8032084fe51a7739e8e2fe28e7042bb114fd6d6abd09cd22af867729ea001c87cd550741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0

When you don't know the order of the contract parameters, you can use the prompt function:

./equity TradeOffer --instance

the commandline tips:

======= TradeOffer =======
Instantiated program:
Error: The number of input arguments 0 is less than the number of contract parameters 4
Usage:
  equity TradeOffer <assetRequested> <amountRequested> <seller> <cancelKey>

The input contract argument description:

type value description
Boolean true/1 , false/0
Integer 0 ~ 2^63-1
Amount -2^63 ~ 2^63-1
Asset hex string with length 64
Hash hex string with length 64
PublicKey hex string with length 64
Program hex string
String string with ASCII, e.g., "this is a test string"

空文件

简介

基于BUTXO编程语言 展开 收起
Go 等 2 种语言
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/BytomBlockchain/equity.git
git@gitee.com:BytomBlockchain/equity.git
BytomBlockchain
equity
equity
master

搜索帮助