Namespace Unsafe

Functions

Link copied to clipboard
function register_crosschain_asset(asset_id: byte_array, name: text, symbol: text, decimals: integer, issuing_blockchain_rid: byte_array, icon_url: text, type: text, uniqueness_resolver: byte_array, origin_blockchain_rid: byte_array): asset_origin

Registers a crosschain asset on this chain. Since this could be used to register many assets and use up a lot of storage space, it is marked as Unsafe

Can only be called from an operation.

Throws "INVALID ORIGIN" when the origin blockchain RID is the blockchain RID of this chain.

Throws "INVALID ISSUING CHAIN" when the issuing blockchain RID is the blockchain RID of this chain.

Throws if the input parameters are invalid. Common cases include:

  • IDs are not 32 bytes long

  • strings are longer than 1024 characters

  • type is empty

  • uniqueness resolver is longer than 1024 bytes

  • decimals is not in the accepted range 0, 78 (inclusive)

  • icon_url is not a valid URL

Link copied to clipboard
function update_balances_if_needed(sender: account, recipient: account, asset: asset, amount: big_integer)

For a transfer going from an account to another, this function checks whether any balances need to be updated, then does so. This function should only be used in the context of crosschain transfers.

A balance does not need to be updated if it pertains to a blockchain that is marked as asset_origin for the asset being transferred. This is because the asset origin chain's balance does not need to be tracked.

Can only be called from an operation.

Throws "SELF TRANSFER" if sender and recipient are the same account

Throws "INVALID BLOCKCHAIN SENDER" if sender is a blockchain account with this blockchain's RID

Throws "INVALID BLOCKCHAIN RECIPIENT" if recipient is a blockchain account with this blockchain's RID

Throws if the required assets cannot be transferred. Common cases include:

  • the amount to transfer is not in the accepted range (0, 2^256) (exclusive)

  • the sender account's balance is lower than amount