Contact Sketch
equity is a language of Bytom smart contract,its a declarative predicate language.
Locked Contract Process
Contract preparation can be constructed by referring to contract templates.Take typical locked publickey for example,its contract nodes are as following:
1contract LockWithPublicKey(publicKey: PublicKey) locks locked {
2 clause unlockWithSig(sig: Signature) {
3 verify checkTxSig(publicKey, sig) unlock locked
4 }
5}
Compile Contract
We advise you to call api to compile contract.You can call by curl command line or postman tool.Curl call:
1curl -X POST http://localhost:9888/create-key -d '{"alias": "alice", "password": "123456"}'
postman:you need to download tool on website
1)bytomd default startup or auth verification,need to access token by curl to call api
1curl -X POST http://localhost:9888/create-access-token -d '{"id":"token1"}'
return results are as following:
1{
2 "token": "token1:1fee70f537128a201338bd5f25a3adbf33dad02eae4f4c9ac43f336a069df8f3",
3 "id": "token1",
4 "created_at": "2018-03-20T18:56:01.043919771+08:00"
5}
2)basic auth verification,fill the username and password of access-token,token1 in the above return results and 1fee70f537128a201338bd5f25a3adbf33dad02eae4f4c9ac43f336a069df8f3
3)If contract parameters include type of PublicKey ,you need to access contract parameters PublicKey through api.Save the results and you will use root_xpub and derivation_path of corresponding pubkey to unlock contract.
4)Compile contract:the program of return results is the lockable contract (compiling contract directly can generate the process of contract perform.If deploying this type of contract,users can construct corresponding parameters to unlock contact)
Construct transactions of locked contract
lock1,000 transactions
777e3586d2ec47c4974d262e0ff86fd3c1c063d242d32bdef71d6d16eed6763e
type of asset into contract
as for details,you can refer to wiki of transaction construction:
https://github.com/Bytom/bytom/wiki/API-Reference#build-transaction
Signature transaction
as for details,you can refer to wiki of signature transaction :
Submit transaction
as for details,you can refer to wiki of submitting transaction
once contract transactions were packaged successfully,you can search specific contents of contract transaction and find corresponding outputID.
The ID field represents outputID
2.According to outputID,search the UTXO of contract through list-unspent-outputs api to see whether the asset type and amount are equal.
3.construct transaction of locked contract,unlock the parameters of clause unlockWithSig to Signature,but the result of signature can obtain after sign-trasaction succeeds.So we only need to construct the signature parameters.
The publicKey we constructed
4e925f0fcc2f2618d96b7a3dce2aad28e60ab3339377760d48aea8ae8169ae41
the parameters of signature are toot_xpub and derivation_path,their corresponding
"dc903a862a14966d47dc6bc935c687c6cccb7a8f9c70f13bb82a41a0fe2696596cb141ff1840f90c75f8f25099f0dc50e005e1e36817d184b2b1eb1354b61575"and
\[ "010400000000000000", "0100000000000000" \]
its construction are as following:
4、signature transaction,you can refer to the wiki of signature transaction for details: https://github.com/Bytom/bytom/wiki/API-Reference#sign-transaction
5.submit transaction,for details: