Skip to main content

Assets

Calls

approveTransfer

Approve an amount of asset for transfer by a delegated third-party account.

Origin must be Signed.

Ensures that ApprovalDeposit worth of Currency is reserved from signing account for the purpose of holding the approval. If some non-zero amount of assets is already approved from signing account to delegate, then it is topped up or unreserved to meet the right value.

NOTE: The signing account does not need to own amount of assets at the point of making this call.

  • id: The identifier of the asset.

  • delegate: The account to delegate permission to transfer asset.

  • amount: The amount of asset that may be transferred by delegate. If there is already an approval in place, then this acts additively.

    Emits ApprovedTransfer on success.

    Weight: O(1)

Namespace

api.tx.assets.approveTransfer

Type

function approveTransfer(
id: Compact<u32>,
delegate: SeedPrimitivesSignatureAccountId20,
amount: Compact<u128>
)

burn

Reduce the balance of who by as much as possible up to amount assets of id.

Origin must be Signed and the sender should be the Manager of the asset id.

Bails with NoAccount if the who is already dead.

  • id: The identifier of the asset to have some amount burned.

  • who: The account to be debited from.

  • amount: The maximum amount by which who's balance should be reduced.

    Emits Burned with the actual amount burned. If this takes the balance to below the minimum for the asset, then the amount burned is increased to take it to zero.

    Weight: O(1) Modes: Post-existence of who; Pre & post Zombie-status of who.

Namespace

api.tx.assets.burn

Type

function burn(
id: Compact<u32>,
who: SeedPrimitivesSignatureAccountId20,
amount: Compact<u128>
)

cancelApproval

Cancel all of some asset approved for delegated transfer by a third-party account.

Origin must be Signed and there must be an approval in place between signer and delegate.

Unreserves any deposit previously reserved by approve_transfer for the approval.

  • id: The identifier of the asset.

  • delegate: The account delegated permission to transfer asset.

    Emits ApprovalCancelled on success.

    Weight: O(1)

Namespace

api.tx.assets.cancelApproval

Type

function cancelApproval(
id: Compact<u32>,
delegate: SeedPrimitivesSignatureAccountId20
)

clearMetadata

Clear the metadata for an asset.

Origin must be Signed and the sender should be the Owner of the asset id.

Any deposit is freed for the asset owner.

  • id: The identifier of the asset to clear.

    Emits MetadataCleared.

    Weight: O(1)

Namespace

api.tx.assets.clearMetadata

Type

function clearMetadata(
id: Compact<u32>
)

create

Issue a new class of fungible assets from a public origin.

This new asset class has no assets initially and its owner is the origin.

The origin must be Signed and the sender must have sufficient funds free.

Funds of sender are reserved by AssetDeposit.

Parameters:

  • id: The identifier of the new asset. This must not be currently in use to identify an existing asset.

  • admin: The admin of this class of assets. The admin is the initial address of each member of the asset class's admin team.

  • min_balance: The minimum balance of this new asset that any single account must have. If an account's balance is reduced below this, then it collapses to zero.

    Emits Created event when successful.

    Weight: O(1)

Namespace

api.tx.assets.create

Type

function create(
id: Compact<u32>,
admin: SeedPrimitivesSignatureAccountId20,
min_balance: u128
)

destroy

Destroy a class of fungible assets.

The origin must conform to ForceOrigin or must be Signed and the sender must be the owner of the asset id.

  • id: The identifier of the asset to be destroyed. This must identify an existing asset.

    Emits Destroyed event when successful.

    NOTE: It can be helpful to first freeze an asset before destroying it so that you can provide accurate witness information and prevent users from manipulating state in a way that can make it harder to destroy.

    Weight: O(c + p + a) where:

  • c = (witness.accounts - witness.sufficients)

  • s = witness.sufficients

  • a = witness.approvals

Namespace

api.tx.assets.destroy

Type

function destroy(
id: Compact<u32>,
witness: PalletAssetsDestroyWitness
)

forceAssetStatus

Alter the attributes of a given asset.

Origin must be ForceOrigin.

  • id: The identifier of the asset.

  • owner: The new Owner of this asset.

  • issuer: The new Issuer of this asset.

  • admin: The new Admin of this asset.

  • freezer: The new Freezer of this asset.

  • min_balance: The minimum balance of this new asset that any single account must have. If an account's balance is reduced below this, then it collapses to zero.

  • is_sufficient: Whether a non-zero balance of this asset is deposit of sufficient value to account for the state bloat associated with its balance storage. If set to true, then non-zero balances may be stored without a consumer reference (and thus an ED in the Balances pallet or whatever else is used to control user-account state growth).

  • is_frozen: Whether this asset class is frozen except for permissioned/admin instructions.

    Emits AssetStatusChanged with the identity of the asset.

    Weight: O(1)

Namespace

api.tx.assets.forceAssetStatus

Type

function forceAssetStatus(
id: Compact<u32>,
owner: SeedPrimitivesSignatureAccountId20,
issuer: SeedPrimitivesSignatureAccountId20,
admin: SeedPrimitivesSignatureAccountId20,
freezer: SeedPrimitivesSignatureAccountId20,
min_balance: Compact<u128>,
is_sufficient: bool,
is_frozen: bool
)

forceCancelApproval

Cancel all of some asset approved for delegated transfer by a third-party account.

Origin must be either ForceOrigin or Signed origin with the signer being the Admin account of the asset id.

Unreserves any deposit previously reserved by approve_transfer for the approval.

  • id: The identifier of the asset.

  • delegate: The account delegated permission to transfer asset.

    Emits ApprovalCancelled on success.

    Weight: O(1)

Namespace

api.tx.assets.forceCancelApproval

Type

function forceCancelApproval(
id: Compact<u32>,
owner: SeedPrimitivesSignatureAccountId20,
delegate: SeedPrimitivesSignatureAccountId20
)

forceClearMetadata

Clear the metadata for an asset.

Origin must be ForceOrigin.

Any deposit is returned.

  • id: The identifier of the asset to clear.

    Emits MetadataCleared.

    Weight: O(1)

Namespace

api.tx.assets.forceClearMetadata

Type

function forceClearMetadata(
id: Compact<u32>
)

forceCreate

Issue a new class of fungible assets from a privileged origin.

This new asset class has no assets initially.

The origin must conform to ForceOrigin.

Unlike create, no funds are reserved.

  • id: The identifier of the new asset. This must not be currently in use to identify an existing asset.

  • owner: The owner of this class of assets. The owner has full superuser permissions over this asset, but may later change and configure the permissions using transfer_ownership and set_team.

  • min_balance: The minimum balance of this new asset that any single account must have. If an account's balance is reduced below this, then it collapses to zero.

    Emits ForceCreated event when successful.

    Weight: O(1)

Namespace

api.tx.assets.forceCreate

Type

function forceCreate(
id: Compact<u32>,
owner: SeedPrimitivesSignatureAccountId20,
is_sufficient: bool,
min_balance: Compact<u128>
)

forceSetMetadata

Force the metadata for an asset to some value.

Origin must be ForceOrigin.

Any deposit is left alone.

  • id: The identifier of the asset to update.

  • name: The user friendly name of this asset. Limited in length by StringLimit.

  • symbol: The exchange symbol for this asset. Limited in length by StringLimit.

  • decimals: The number of decimals this asset uses to represent one unit.

    Emits MetadataSet.

    Weight: O(N + S) where N and S are the length of the name and symbol respectively.

Namespace

api.tx.assets.forceSetMetadata

Type

function forceSetMetadata(
id: Compact<u32>,
name: Bytes,
symbol: Bytes,
decimals: u8,
is_frozen: bool
)

forceTransfer

Move some assets from one account to another.

Origin must be Signed and the sender should be the Admin of the asset id.

  • id: The identifier of the asset to have some amount transferred.

  • source: The account to be debited.

  • dest: The account to be credited.

  • amount: The amount by which the source's balance of assets should be reduced and dest's balance increased. The amount actually transferred may be slightly greater in the case that the transfer would otherwise take the source balance above zero but below the minimum balance. Must be greater than zero.

    Emits Transferred with the actual amount transferred. If this takes the source balance to below the minimum for the asset, then the amount transferred is increased to take it to zero.

    Weight: O(1) Modes: Pre-existence of dest; Post-existence of source; Account pre-existence of dest.

Namespace

api.tx.assets.forceTransfer

Type

function forceTransfer(
id: Compact<u32>,
source: SeedPrimitivesSignatureAccountId20,
dest: SeedPrimitivesSignatureAccountId20,
amount: Compact<u128>
)

freeze

Disallow further unprivileged transfers from an account.

Origin must be Signed and the sender should be the Freezer of the asset id.

  • id: The identifier of the asset to be frozen.

  • who: The account to be frozen.

    Emits Frozen.

    Weight: O(1)

Namespace

api.tx.assets.freeze

Type

function freeze(
id: Compact<u32>,
who: SeedPrimitivesSignatureAccountId20
)

freezeAsset

Disallow further unprivileged transfers for the asset class.

Origin must be Signed and the sender should be the Freezer of the asset id.

  • id: The identifier of the asset to be frozen.

    Emits Frozen.

    Weight: O(1)

Namespace

api.tx.assets.freezeAsset

Type

function freezeAsset(
id: Compact<u32>
)

mint

Mint assets of a particular class.

The origin must be Signed and the sender must be the Issuer of the asset id.

  • id: The identifier of the asset to have some amount minted.

  • beneficiary: The account to be credited with the minted assets.

  • amount: The amount of the asset to be minted.

    Emits Issued event when successful.

    Weight: O(1) Modes: Pre-existing balance of beneficiary; Account pre-existence of beneficiary.

Namespace

api.tx.assets.mint

Type

function mint(
id: Compact<u32>,
beneficiary: SeedPrimitivesSignatureAccountId20,
amount: Compact<u128>
)

refund

Return the deposit (if any) of an asset account.

The origin must be Signed.

  • id: The identifier of the asset for the account to be created.

  • allow_burn: If true then assets may be destroyed in order to complete the refund.

    Emits Refunded event when successful.

Namespace

api.tx.assets.refund

Type

function refund(
id: Compact<u32>,
allow_burn: bool
)

setMetadata

Set the metadata for an asset.

Origin must be Signed and the sender should be the Owner of the asset id.

Funds of sender are reserved according to the formula: MetadataDepositBase + MetadataDepositPerByte * (name.len + symbol.len) taking into account any already reserved funds.

  • id: The identifier of the asset to update.

  • name: The user friendly name of this asset. Limited in length by StringLimit.

  • symbol: The exchange symbol for this asset. Limited in length by StringLimit.

  • decimals: The number of decimals this asset uses to represent one unit.

    Emits MetadataSet.

    Weight: O(1)

Namespace

api.tx.assets.setMetadata

Type

function setMetadata(
id: Compact<u32>,
name: Bytes,
symbol: Bytes,
decimals: u8
)

setTeam

Change the Issuer, Admin and Freezer of an asset.

Origin must be Signed and the sender should be the Owner of the asset id.

  • id: The identifier of the asset to be frozen.

  • issuer: The new Issuer of this asset.

  • admin: The new Admin of this asset.

  • freezer: The new Freezer of this asset.

    Emits TeamChanged.

    Weight: O(1)

Namespace

api.tx.assets.setTeam

Type

function setTeam(
id: Compact<u32>,
issuer: SeedPrimitivesSignatureAccountId20,
admin: SeedPrimitivesSignatureAccountId20,
freezer: SeedPrimitivesSignatureAccountId20
)

thaw

Allow unprivileged transfers from an account again.

Origin must be Signed and the sender should be the Admin of the asset id.

  • id: The identifier of the asset to be frozen.

  • who: The account to be unfrozen.

    Emits Thawed.

    Weight: O(1)

Namespace

api.tx.assets.thaw

Type

function thaw(
id: Compact<u32>,
who: SeedPrimitivesSignatureAccountId20
)

thawAsset

Allow unprivileged transfers for the asset again.

Origin must be Signed and the sender should be the Admin of the asset id.

  • id: The identifier of the asset to be thawed.

    Emits Thawed.

    Weight: O(1)

Namespace

api.tx.assets.thawAsset

Type

function thawAsset(
id: Compact<u32>
)

touch

Create an asset account for non-provider assets.

A deposit will be taken from the signer account.

  • origin: Must be Signed; the signer account must have sufficient funds for a deposit to be taken.

  • id: The identifier of the asset for the account to be created.

    Emits Touched event when successful.

Namespace

api.tx.assets.touch

Type

function touch(
id: Compact<u32>
)

transfer

Move some assets from the sender account to another.

Origin must be Signed.

  • id: The identifier of the asset to have some amount transferred.

  • target: The account to be credited.

  • amount: The amount by which the sender's balance of assets should be reduced and target's balance increased. The amount actually transferred may be slightly greater in the case that the transfer would otherwise take the sender balance above zero but below the minimum balance. Must be greater than zero.

    Emits Transferred with the actual amount transferred. If this takes the source balance to below the minimum for the asset, then the amount transferred is increased to take it to zero.

    Weight: O(1) Modes: Pre-existence of target; Post-existence of sender; Account pre-existence of target.

Namespace

api.tx.assets.transfer

Type

function transfer(
id: Compact<u32>,
target: SeedPrimitivesSignatureAccountId20,
amount: Compact<u128>
)

transferApproved

Transfer some asset balance from a previously delegated account to some third-party account.

Origin must be Signed and there must be an approval in place by the owner to the signer.

If the entire amount approved for transfer is transferred, then any deposit previously reserved by approve_transfer is unreserved.

  • id: The identifier of the asset.

  • owner: The account which previously approved for a transfer of at least amount and from which the asset balance will be withdrawn.

  • destination: The account to which the asset balance of amount will be transferred.

  • amount: The amount of assets to transfer.

    Emits TransferredApproved on success.

    Weight: O(1)

Namespace

api.tx.assets.transferApproved

Type

function transferApproved(
id: Compact<u32>,
owner: SeedPrimitivesSignatureAccountId20,
destination: SeedPrimitivesSignatureAccountId20,
amount: Compact<u128>
)

transferKeepAlive

Move some assets from the sender account to another, keeping the sender account alive.

Origin must be Signed.

  • id: The identifier of the asset to have some amount transferred.

  • target: The account to be credited.

  • amount: The amount by which the sender's balance of assets should be reduced and target's balance increased. The amount actually transferred may be slightly greater in the case that the transfer would otherwise take the sender balance above zero but below the minimum balance. Must be greater than zero.

    Emits Transferred with the actual amount transferred. If this takes the source balance to below the minimum for the asset, then the amount transferred is increased to take it to zero.

    Weight: O(1) Modes: Pre-existence of target; Post-existence of sender; Account pre-existence of target.

Namespace

api.tx.assets.transferKeepAlive

Type

function transferKeepAlive(
id: Compact<u32>,
target: SeedPrimitivesSignatureAccountId20,
amount: Compact<u128>
)

transferOwnership

Change the Owner of an asset.

Origin must be Signed and the sender should be the Owner of the asset id.

  • id: The identifier of the asset.

  • owner: The new Owner of this asset.

    Emits OwnerChanged.

    Weight: O(1)

Namespace

api.tx.assets.transferOwnership

Type

function transferOwnership(
id: Compact<u32>,
owner: SeedPrimitivesSignatureAccountId20
)

Storage

account

The holdings of a specific account for a specific asset.

Namespace

api.query.assets.account

Type

function account(
u32,
SeedPrimitivesSignatureAccountId20
): Option<PalletAssetsAssetAccount>

approvals

Approved balance transfers. First balance is the amount approved for transfer. Second is the amount of T::Currency reserved for storing this. First key is the asset ID, second key is the owner and third key is the delegate.

Namespace

api.query.assets.approvals

Type

function approvals(
u32,
SeedPrimitivesSignatureAccountId20,
SeedPrimitivesSignatureAccountId20
): Option<PalletAssetsApproval>

asset

Details of an asset.

Namespace

api.query.assets.asset

Type

function asset(
u32
): Option<PalletAssetsAssetDetails>

metadata

Metadata of an asset.

Namespace

api.query.assets.metadata

Type

function metadata(
u32
): PalletAssetsAssetMetadata

Events

ApprovalCancelled

An approval for account delegate was cancelled by owner.

Namespace

api.events.assets.ApprovalCancelled

Type

type ApprovalCancelled = {
asset_id: u32,
owner: SeedPrimitivesSignatureAccountId20,
delegate: SeedPrimitivesSignatureAccountId20
}

ApprovedTransfer

(Additional) funds have been approved for transfer to a destination account.

Namespace

api.events.assets.ApprovedTransfer

Type

type ApprovedTransfer = {
asset_id: u32,
source: SeedPrimitivesSignatureAccountId20,
delegate: SeedPrimitivesSignatureAccountId20,
amount: u128
}

AssetFrozen

Some asset asset_id was frozen.

Namespace

api.events.assets.AssetFrozen

Type

type AssetFrozen = {
asset_id: u32
}

AssetStatusChanged

An asset has had its attributes changed by the Force origin.

Namespace

api.events.assets.AssetStatusChanged

Type

type AssetStatusChanged = {
asset_id: u32
}

AssetThawed

Some asset asset_id was thawed.

Namespace

api.events.assets.AssetThawed

Type

type AssetThawed = {
asset_id: u32
}

Burned

Some assets were destroyed.

Namespace

api.events.assets.Burned

Type

type Burned = {
asset_id: u32,
owner: SeedPrimitivesSignatureAccountId20,
balance: u128
}

Created

Some asset class was created.

Namespace

api.events.assets.Created

Type

type Created = {
asset_id: u32,
creator: SeedPrimitivesSignatureAccountId20,
owner: SeedPrimitivesSignatureAccountId20
}

Destroyed

An asset class was destroyed.

Namespace

api.events.assets.Destroyed

Type

type Destroyed = {
asset_id: u32
}

ForceCreated

Some asset class was force-created.

Namespace

api.events.assets.ForceCreated

Type

type ForceCreated = {
asset_id: u32,
owner: SeedPrimitivesSignatureAccountId20
}

Frozen

Some account who was frozen.

Namespace

api.events.assets.Frozen

Type

type Frozen = {
asset_id: u32,
who: SeedPrimitivesSignatureAccountId20
}

Issued

Some assets were issued.

Namespace

api.events.assets.Issued

Type

type Issued = {
asset_id: u32,
owner: SeedPrimitivesSignatureAccountId20,
total_supply: u128
}

MetadataCleared

Metadata has been cleared for an asset.

Namespace

api.events.assets.MetadataCleared

Type

type MetadataCleared = {
asset_id: u32
}

MetadataSet

New metadata has been set for an asset.

Namespace

api.events.assets.MetadataSet

Type

type MetadataSet = {
asset_id: u32,
name: Bytes,
symbol: Bytes,
decimals: u8,
is_frozen: bool
}

OwnerChanged

The owner changed.

Namespace

api.events.assets.OwnerChanged

Type

type OwnerChanged = {
asset_id: u32,
owner: SeedPrimitivesSignatureAccountId20
}

TeamChanged

The management team changed.

Namespace

api.events.assets.TeamChanged

Type

type TeamChanged = {
asset_id: u32,
issuer: SeedPrimitivesSignatureAccountId20,
admin: SeedPrimitivesSignatureAccountId20,
freezer: SeedPrimitivesSignatureAccountId20
}

Thawed

Some account who was thawed.

Namespace

api.events.assets.Thawed

Type

type Thawed = {
asset_id: u32,
who: SeedPrimitivesSignatureAccountId20
}

Transferred

Some assets were transferred.

Namespace

api.events.assets.Transferred

Type

type Transferred = {
asset_id: u32,
from: SeedPrimitivesSignatureAccountId20,
to: SeedPrimitivesSignatureAccountId20,
amount: u128
}

TransferredApproved

An amount was transferred in its entirety from owner to destination by the approved delegate.

Namespace

api.events.assets.TransferredApproved

Type

type TransferredApproved = {
asset_id: u32,
owner: SeedPrimitivesSignatureAccountId20,
delegate: SeedPrimitivesSignatureAccountId20,
destination: SeedPrimitivesSignatureAccountId20,
amount: u128
}

Errors

AlreadyExists

The asset-account already exists.

Namespace

api.errors.assets.AlreadyExists

BadMetadata

Invalid metadata given.

Namespace

api.errors.assets.BadMetadata

BadWitness

Invalid witness data given.

Namespace

api.errors.assets.BadWitness

BalanceLow

Account balance must be greater than or equal to the transfer amount.

Namespace

api.errors.assets.BalanceLow

Frozen

The origin account is frozen.

Namespace

api.errors.assets.Frozen

InUse

The asset ID is already taken.

Namespace

api.errors.assets.InUse

MinBalanceZero

Minimum balance should be non-zero.

Namespace

api.errors.assets.MinBalanceZero

NoAccount

The account to alter does not exist.

Namespace

api.errors.assets.NoAccount

NoDeposit

The asset-account doesn't have an associated deposit.

Namespace

api.errors.assets.NoDeposit

NoPermission

The signing account has no permission to do the operation.

Namespace

api.errors.assets.NoPermission

NoProvider

Unable to increment the consumer reference counters on the account. Either no provider reference exists to allow a non-zero balance of a non-self-sufficient asset, or the maximum number of consumers has been reached.

Namespace

api.errors.assets.NoProvider

Unapproved

No approval exists that would allow the transfer.

Namespace

api.errors.assets.Unapproved

Unknown

The given asset ID is unknown.

Namespace

api.errors.assets.Unknown

WouldBurn

The operation would result in funds being burned.

Namespace

api.errors.assets.WouldBurn

WouldDie

The source account would not survive the transfer and it needs to stay alive.

Namespace

api.errors.assets.WouldDie

Constants

approvalDeposit

The amount of funds that must be reserved when creating a new approval.

Namespace

api.consts.assets.approvalDeposit

Type

type approvalDeposit = u128

assetAccountDeposit

The amount of funds that must be reserved for a non-provider asset account to be maintained.

Namespace

api.consts.assets.assetAccountDeposit

Type

type assetAccountDeposit = u128

assetDeposit

The basic amount of funds that must be reserved for an asset.

Namespace

api.consts.assets.assetDeposit

Type

type assetDeposit = u128

metadataDepositBase

The basic amount of funds that must be reserved when adding metadata to your asset.

Namespace

api.consts.assets.metadataDepositBase

Type

type metadataDepositBase = u128

metadataDepositPerByte

The additional funds that must be reserved for the number of bytes you store in your metadata.

Namespace

api.consts.assets.metadataDepositPerByte

Type

type metadataDepositPerByte = u128

stringLimit

The maximum length of a name or symbol stored on-chain.

Namespace

api.consts.assets.stringLimit

Type

type stringLimit = u32