Built-in Functions
The built-in functions are divided into several categories:
Contract,
SubContract,
Map,
Asset,
Utils,
Chain,
Conversion,
ByteVec,
Cryptography,
Test.
All built-in functions are suffixed with !
.
All of the byte encoding use Big Endian byte order.
Contract Functions
encodeFields
fn <ContractName>.encodeFields!(...) -> (ByteVec, ByteVec)
Encode the fields for creating a contract
@param ... the fields of the to-be-created target contract
@returns two ByteVecs: the first one is the encoded immutable fields, and the second one is the encoded mutable fields
createContract
fn createContract!(bytecode:ByteVec, encodedImmFields:ByteVec, encodedMutFields:ByteVec) -> (ByteVec)
Creates a new contract without token issuance.
@param bytecode the bytecode of the contract to be created
@param encodedImmFields the encoded immutable fields as a ByteVec
@param encodedMutFields the encoded mutable fields as a ByteVec
@returns the id of the created contract
createContractWithToken
fn createContractWithToken!(bytecode:ByteVec, encodedImmFields:ByteVec, encodedMutFields:ByteVec, issueTokenAmount:U256, issueTo?:Address) -> (ByteVec)
Creates a new contract with token issuance.
@param bytecode the bytecode of the contract to be created
@param encodedImmFields the encoded immutable fields as a ByteVec
@param encodedMutFields the encoded mutable fields as a ByteVec
@param issueTokenAmount the amount of token to be issued
@param issueTo (optional) a designated address to receive issued token
@returns the id of the created contract
copyCreateContract
fn copyCreateContract!(contractId:ByteVec, encodedImmFields:ByteVec, encodedMutFields:ByteVec) -> (ByteVec)
Creates a new contract without token issuance by copying another contract's code. This costs less gas than createContract!(...).
@param contractId the id of the contract to be copied
@param encodedImmFields the encoded immutable fields as a ByteVec
@param encodedMutFields the encoded mutable fields as a ByteVec
@returns the id of the created contract
copyCreateContractWithToken
fn copyCreateContractWithToken!(contractId:ByteVec, encodedImmFields:ByteVec, encodedMutFields:ByteVec, issueTokenAmount:U256, issueTo?:Address) -> (ByteVec)
Creates a new contract with token issuance by copying another contract's code. This costs less gas than createContractWithToken!(...).
@param contractId the id of the contract to be copied
@param encodedImmFields the encoded immutable fields as a ByteVec
@param encodedMutFields the encoded mutable fields as a ByteVec
@param issueTokenAmount the amount of token to be issued
@param issueTo (optional) a designated address to receive issued token
@returns the id of the created contract
selfAddress
fn selfAddress!() -> (Address)
Returns the address of the contract.
@returns the address of the contract