Contract module
The Contract module contains functions that deals with current and other contracts.
call_function/3 [I/O]
Contract.call_function(0x0000ABCD..., "add", [1, 2])
Parameters:
contract_addressthe contract's adddressfunction_namethe function nameargsthe list of arguments to call the function with
Calls the exported function function_name of the Smart Contract at contract_address with given args and return the result value.
set_type/1 [Transaction]
Contract.set_type("transfer")
Parameters:
typethe transaction type ("contract", "transfer", "data", "hosting")
Mutates the next transaction to be of type type.
set_content/1 [Transaction]
Contract.set_content("Hello Smart Contract")
Parameters:
contentthe transaction's content (we usually use this as the state of the smart contract)
Mutates the next transaction content to be content.
While content is always a string when you read it, it is possible here to send an integer or a float for convenience.
For any other data structure, you should serialize it with the Json module for example.
set_code/1 [Transaction]
Contract.set_code("@version 1\ncondition inherit: []")
Parameters:
codethe code
Mutates the next transaction code to be code.
This example "closes" the contract, by adding an condition inherit that doesn't accept anything. It will be impossible to create a new transaction in this chain.
add_uco_transfer/1 [Transaction]
Contract.add_uco_transfer(to: "000012345...", amount: 1)
Parameters:
uco_transfera map with two keys:to: the destination addressamount: the number of UCO
Mutates the next transaction to add the uco_transfer.
add_uco_transfers/1 [Transaction]
Equivalent to call add_uco_transfer/1 for each element of the list
add_token_transfer/1 [Transaction]
Contract.add_token_transfer(
to: "000012345...",
amount: 1.2,
token_address: "000023456...")
Contract.add_token_transfer(
to: "000012345...",
amount: 1.2,
token_id: 4,
token_address: "000023456...")
Parameters:
token_transfera map with three or four keys:to: the destination addressamount: the number of UCOtoken_address: the transaction address of the token[token_id]: an optional integer to specify which index in the list (used for the NFTs)
Mutates the next transaction to add the token_transfer.
add_token_transfers/1 [Transaction]
Equivalent to call add_token_transfer/1 for each element of the list
add_ownership/1 [Transaction]
authorized_keys = Map.new()
authorized_keys = Map.set(authorized_keys, public_key, encoded_secret_key)
Contract.add_ownership(
secret: "ENCODED_SECRET1",
authorized_keys: authorized_keys
)
Parameters:
ownershipa map with two keys:secret: the encoded secretauthorized_keys: a map where the keys are thepublic_keysand the values are theencoded_secret_keys(the keys to decode the secret encoded by eachpublic_key)
It is the developer's job to encode the secret & the secret key for each authorized key.
Mutates the next transaction to add the ownership.
add_ownerships/1 [Transaction]
Equivalent to call add_ownership/1 for each element of the list
add_recipient/1 [Transaction]
Contract.add_recipient("000012345...")
Parameters:
address: a transaction address (one with a smart contract)
Mutates the next transaction to add the address in the recipients.
Recipients are used to trigger smart contracts
add_recipients/1 [Transaction]
Equivalent to call add_recipients/1 for each element of the list