Active Contract Set
GET
http://127.0.0.1:31567/contract/active
Returns all currently active contracts. May not be accurate until the blockchain is fully synced.
[
{
"contractHash": "55be2edd1e537869cce832bd014aa1e3251aba651c5c3f38f70db86417faa9c4",
"address": "tc1q2klzahg72duxnn8gx27szj4puvj34wn9r3wr7w8hpkuxg9l648zqhc76xa",
"expire": 19375,
"code": "(* NAME_START: Example Token :NAME_END *)\nopen Zen.Types\nopen Zen.Vector\nopen Zen.Base\nopen Zen.Cost\nopen Zen.Asset\nopen Zen.Data\n\nmodule ET = Zen.ErrorT\nmodule OT = Zen.OptionT\nmodule Tx = Zen.TxSkeleton\nmodule CR = Zen.ContractResult.NoMessage\n\nlet buy txSkeleton contractHash returnAddress =\n let! tokens = Tx.getAvailableTokens zenAsset txSkeleton in\n\n let! contractAsset = getDefault contractHash in\n\n let! txSkeleton =\n Tx.lockToContract zenAsset tokens contractHash txSkeleton\n >>= Tx.mint tokens contractAsset\n >>= Tx.lockToAddress contractAsset tokens returnAddress in\n\n CR.ret txSkeleton\n\nlet redeem txSkeleton contractHash returnAddress wallet =\n let! contractAsset = getDefault contractHash in\n let! tokens = Tx.getAvailableTokens contractAsset txSkeleton in\n\n let! txSkeleton =\n Tx.destroy tokens contractAsset txSkeleton\n >>= Tx.lockToAddress zenAsset tokens returnAddress\n >>= Tx.fromWallet zenAsset tokens contractHash wallet in\n\n CR.ofOption \"contract doesn't have enough zens to pay you\" txSkeleton\n\nval main: txSkeleton -> hash -> string -> option data -> wallet:wallet -> cost (result (txSkeleton ** option message)) (2 + 66 + (64 + (64 + (64 + 64 + (Zen.Wallet.size wallet * 128 + 192) + 0)) + 25) + 29)\nlet main txSkeleton contractHash command data wallet =\n let! returnAddress = data >!> tryDict >?> tryFindLock \"returnAddress\" in\n\n match returnAddress with\n | Some returnAddress ->\n if command = \"redeem\" then\n redeem txSkeleton contractHash returnAddress wallet\n else if command = \"\" || command = \"buy\" then\n buy txSkeleton contractHash returnAddress\n |> autoInc\n else\n ET.autoFailw \"unsupported command\"\n | None ->\n ET.autoFailw \"returnAddress is required\"\n\nval cf: txSkeleton -> string -> option data -> wallet -> cost nat 24\nlet cf _ _ _ wallet = ret (2 + 66 + (64 + (64 + (64 + 64 + (Zen.Wallet.size wallet * 128 + 192) + 0)) + 25) + 29)"
},
{
"contractHash": "55be2edd1e537869cce832bd014aa1e3251aba651c5c3f38f70db86417faa9c4",
"address": "tc1q2klzahg72duxnn8gx27szj4puvj34wn9r3wr7w8hpkuxg9l648zqhc76xa",
"expire": 19375,
"code": "(* NAME_START: Example Token :NAME_END *)\nopen Zen.Types\nopen Zen.Vector\nopen Zen.Base\nopen Zen.Cost\nopen Zen.Asset\nopen Zen.Data\n\nmodule ET = Zen.ErrorT\nmodule OT = Zen.OptionT\nmodule Tx = Zen.TxSkeleton\nmodule CR = Zen.ContractResult.NoMessage\n\nlet buy txSkeleton contractHash returnAddress =\n let! tokens = Tx.getAvailableTokens zenAsset txSkeleton in\n\n let! contractAsset = getDefault contractHash in\n\n let! txSkeleton =\n Tx.lockToContract zenAsset tokens contractHash txSkeleton\n >>= Tx.mint tokens contractAsset\n >>= Tx.lockToAddress contractAsset tokens returnAddress in\n\n CR.ret txSkeleton\n\nlet redeem txSkeleton contractHash returnAddress wallet =\n let! contractAsset = getDefault contractHash in\n let! tokens = Tx.getAvailableTokens contractAsset txSkeleton in\n\n let! txSkeleton =\n Tx.destroy tokens contractAsset txSkeleton\n >>= Tx.lockToAddress zenAsset tokens returnAddress\n >>= Tx.fromWallet zenAsset tokens contractHash wallet in\n\n CR.ofOption \"contract doesn't have enough zens to pay you\" txSkeleton\n\nval main: txSkeleton -> hash -> string -> option data -> wallet:wallet -> cost (result (txSkeleton ** option message)) (2 + 66 + (64 + (64 + (64 + 64 + (Zen.Wallet.size wallet * 128 + 192) + 0)) + 25) + 29)\nlet main txSkeleton contractHash command data wallet =\n let! returnAddress = data >!> tryDict >?> tryFindLock \"returnAddress\" in\n\n match returnAddress with\n | Some returnAddress ->\n if command = \"redeem\" then\n redeem txSkeleton contractHash returnAddress wallet\n else if command = \"\" || command = \"buy\" then\n buy txSkeleton contractHash returnAddress\n |> autoInc\n else\n ET.autoFailw \"unsupported command\"\n | None ->\n ET.autoFailw \"returnAddress is required\"\n\nval cf: txSkeleton -> string -> option data -> wallet -> cost nat 24\nlet cf _ _ _ wallet = ret (2 + 66 + (64 + (64 + (64 + 64 + (Zen.Wallet.size wallet * 128 + 192) + 0)) + 25) + 29)"
}
]
Contract ID
GET
http://127.0.0.1:31567/contract/contractId
Get a contract identifier from a contract address.
Path Parameters
00000000e89738718a802a7d217941882efe8e585e20b20901391bc37af25fac2f22c8ab
invalid address map
[("address",
"notExistingContractAddress")]
Activate Contract
POST
http://127.0.0.1:31567/wallet/contract/activate
This how you activate a contract
Request Body
The number of blocks you want to activate your contract for
Send valid fstar code, for example:
let main _ _ _ _ _ _ _ _ = Zen.ResultT.failw \"This contract does nothing\"\nlet cf _ _ _ _ _ _ _ = Zen.Cost.ret (1 <: nat)
{
"address": "ctzn1qqqqqqqym4kfe8y5qg5tazkgjwn4qpesj05x6mqsvd5auwmzkhhs444fnkvwxhahr",
"contractId": "000000009bad939392804517d1591274ea00e6127d0dad820c6d3bc76c56bde15ad533b3"
}
Execute Contract
POST
http://127.0.0.1:31567/wallet/contract/execute
Run a smart contract with parameters
Request Body
add sign and return address here if needed
the derivation path for the execution of the contract
allows the contract to automatically send funds back to in case it needs to.
send the contract some data
Trigger one of the functions in the contract
5222c826d8d403636a75f48fd91d7d177be6efbf04ac266f3822322733e938ad
Extend Contract
POST
http://127.0.0.1:31567/wallet/contract/extend
This is to extend a contract
Request Body
Number of block until when the contract will be active
5222c826d8d403636a75f48fd91d7d177be6efbf04ac266f3822322733e938ad