Trait frc46_token::token::types::FRC46Token

source ·
pub trait FRC46Token {
    type TokenError;

Show 13 methods // Required methods fn name(&self) -> String; fn symbol(&self) -> String; fn granularity(&self) -> GranularityReturn; fn total_supply(&mut self) -> TotalSupplyReturn; fn balance_of( &mut self, params: Address, ) -> Result<BalanceReturn, Self::TokenError>; fn allowance( &mut self, params: GetAllowanceParams, ) -> Result<AllowanceReturn, Self::TokenError>; fn transfer( &mut self, params: TransferParams, ) -> Result<TransferReturn, Self::TokenError>; fn transfer_from( &mut self, params: TransferFromParams, ) -> Result<TransferFromReturn, Self::TokenError>; fn increase_allowance( &mut self, params: IncreaseAllowanceParams, ) -> Result<IncreaseAllowanceReturn, Self::TokenError>; fn decrease_allowance( &mut self, params: DecreaseAllowanceParams, ) -> Result<DecreaseAllowanceReturn, Self::TokenError>; fn revoke_allowance( &mut self, params: RevokeAllowanceParams, ) -> Result<RevokeAllowanceReturn, Self::TokenError>; fn burn( &mut self, params: BurnParams, ) -> Result<BurnReturn, Self::TokenError>; fn burn_from( &mut self, params: BurnFromParams, ) -> Result<BurnFromReturn, Self::TokenError>;
}
Expand description

A standard fungible token interface allowing for on-chain transactions that implements the FRC-0046 standard. This represents the external interface exposed to other on-chain actors

Token authors must implement this trait and link the methods to standard dispatch numbers (as defined by FRC-0042).

Required Associated Types§

Required Methods§

source

fn name(&self) -> String

Returns the name of the token

Must not be empty

source

fn symbol(&self) -> String

Returns the ticker symbol of the token

Must not be empty. Should be a short uppercase string

source

fn granularity(&self) -> GranularityReturn

Returns the smallest amount of tokens which is indivisible.

All transfers, burns, and mints must be a whole multiple of the granularity. All balances must be a multiple of this granularity (but allowances need not be). Must be at least 1. Must never change.

A granularity of 10^18 corresponds to whole units only, with no further decimal precision.

source

fn total_supply(&mut self) -> TotalSupplyReturn

Returns the total amount of the token in existence

Must be non-negative. The total supply must equal the balances of all addresses. The total supply should equal the sum of all minted tokens less the sum of all burnt tokens.

source

fn balance_of( &mut self, params: Address, ) -> Result<BalanceReturn, Self::TokenError>

Returns the balance of an address

Balance is always non-negative. Uninitialised addresses have an implicit zero balance.

source

fn allowance( &mut self, params: GetAllowanceParams, ) -> Result<AllowanceReturn, Self::TokenError>

Returns the allowance approved for an operator on a spender’s balance

The operator can burn or transfer the allowance amount out of the owner’s address.

source

fn transfer( &mut self, params: TransferParams, ) -> Result<TransferReturn, Self::TokenError>

Transfers tokens from the caller to another address

Amount must be non-negative (but can be zero). Transferring to the caller’s own address must be treated as a normal transfer. Must call the receiver hook on the receiver’s address, failing and aborting the transfer if calling the hook fails or aborts.

source

fn transfer_from( &mut self, params: TransferFromParams, ) -> Result<TransferFromReturn, Self::TokenError>

Transfers tokens from one address to another

The caller must have previously approved to control at least the sent amount. If successful, the amount transferred is deducted from the caller’s allowance.

source

fn increase_allowance( &mut self, params: IncreaseAllowanceParams, ) -> Result<IncreaseAllowanceReturn, Self::TokenError>

Atomically increases the approved allowance that a operator can transfer/burn from the caller’s balance

The increase must be non-negative. Returns the new total allowance approved for that owner-operator pair.

source

fn decrease_allowance( &mut self, params: DecreaseAllowanceParams, ) -> Result<DecreaseAllowanceReturn, Self::TokenError>

Atomically decreases the approved balance that a operator can transfer/burn from the caller’s balance

The decrease must be non-negative. Sets the allowance to zero if the decrease is greater than the currently approved allowance. Returns the new total allowance approved for that owner-operator pair.

source

fn revoke_allowance( &mut self, params: RevokeAllowanceParams, ) -> Result<RevokeAllowanceReturn, Self::TokenError>

Sets the allowance a operator has on the owner’s account to zero

source

fn burn(&mut self, params: BurnParams) -> Result<BurnReturn, Self::TokenError>

Burns tokens from the caller’s balance, decreasing the total supply

source

fn burn_from( &mut self, params: BurnFromParams, ) -> Result<BurnFromReturn, Self::TokenError>

Burns tokens from an address’s balance

The caller must have been previously approved to control at least the burnt amount.

Implementors§