3 The equity compiler tool is the equity commandline compiler.
7 [Go](https://golang.org/doc/install) version 1.8 or higher, with `$GOPATH` set to your preferred directory
9 Build source code, the build target of the equity compiler commandline tool is `equity`.
15 then change directory to `equity`, and you can find the tool `equity` :
20 ## Usage on the commandline
22 Usage of equity commandline compiler:
24 $ ./equity <input_file> [flags]
27 Using help provides you with an explanation of all options.
35 --bin Binary of the contracts in hex.
36 --instance Object of the Instantiated contracts.
37 --shift Function shift of the contracts.
42 The contents of the contract file `TradeOffer`(without file suffix restrictions) are as follows:
44 contract TradeOffer(assetRequested: Asset,
45 amountRequested: Amount,
47 cancelKey: PublicKey) locks valueAmount of valueAsset {
49 lock amountRequested of assetRequested with seller
50 unlock valueAmount of valueAsset
52 clause cancel(sellerSig: Signature) {
53 verify checkTxSig(cancelKey, sellerSig)
54 unlock valueAmount of valueAsset
59 - Compiler contract file to generate the binary:
61 ./equity TradeOffer --bin
66 ======= TradeOffer =======
68 547a6413000000007b7b51547ac1631a000000547a547aae7cac
71 - Query the clause shift for contract:
73 ./equity TradeOffer --shift
78 ======= TradeOffer =======
86 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.
88 - Instantiated contract with arguments:
90 ./equity TradeOffer --instance 84fe51a7739e8e2fe28e7042bb114fd6d6abd09cd22af867729ea001c87cd550 1000 0014d6598ab7dce6b04d43f31ad6eed76b18da553e94 7975f3f71ca7f55ecdef53ccf44224d514bc584bc065770bba8dcdb9d7f9ae6c
95 ======= TradeOffer =======
97 207975f3f71ca7f55ecdef53ccf44224d514bc584bc065770bba8dcdb9d7f9ae6c160014d6598ab7dce6b04d43f31ad6eed76b18da553e9402e8032084fe51a7739e8e2fe28e7042bb114fd6d6abd09cd22af867729ea001c87cd550741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0
100 When you don't know the order of the contract parameters, you can use the prompt function:
102 ./equity TradeOffer --instance
105 the commandline tips:
107 ======= TradeOffer =======
108 Instantiated program:
109 Error: The number of input arguments 0 is less than the number of contract parameters 4
111 equity TradeOffer <assetRequested> <amountRequested> <seller> <cancelKey>
114 The input contract argument description:
116 | type | value description |
117 | ---- | ----------- |
118 | Boolean | true/1 , false/0 |
119 | Integer | 0 ~ 2^63-1 |
120 | Amount | -2^63 ~ 2^63-1 |
121 | Asset | hex string with length 64 |
122 | Hash | hex string with length 64 |
123 | PublicKey | hex string with length 64 |
124 | Program | hex string |
125 | String | string with ASCII, e.g., "this is a test string" |