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§
type TokenError
Required Methods§
sourcefn symbol(&self) -> String
fn symbol(&self) -> String
Returns the ticker symbol of the token
Must not be empty. Should be a short uppercase string
sourcefn granularity(&self) -> GranularityReturn
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.
sourcefn total_supply(&mut self) -> TotalSupplyReturn
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.
sourcefn balance_of(
&mut self,
params: Address,
) -> Result<BalanceReturn, Self::TokenError>
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.
sourcefn allowance(
&mut self,
params: GetAllowanceParams,
) -> Result<AllowanceReturn, Self::TokenError>
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.
sourcefn transfer(
&mut self,
params: TransferParams,
) -> Result<TransferReturn, Self::TokenError>
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.
sourcefn transfer_from(
&mut self,
params: TransferFromParams,
) -> Result<TransferFromReturn, Self::TokenError>
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.
sourcefn increase_allowance(
&mut self,
params: IncreaseAllowanceParams,
) -> Result<IncreaseAllowanceReturn, Self::TokenError>
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.
sourcefn decrease_allowance(
&mut self,
params: DecreaseAllowanceParams,
) -> Result<DecreaseAllowanceReturn, Self::TokenError>
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.
sourcefn revoke_allowance(
&mut self,
params: RevokeAllowanceParams,
) -> Result<RevokeAllowanceReturn, Self::TokenError>
fn revoke_allowance( &mut self, params: RevokeAllowanceParams, ) -> Result<RevokeAllowanceReturn, Self::TokenError>
Sets the allowance a operator has on the owner’s account to zero
sourcefn burn(&mut self, params: BurnParams) -> Result<BurnReturn, Self::TokenError>
fn burn(&mut self, params: BurnParams) -> Result<BurnReturn, Self::TokenError>
Burns tokens from the caller’s balance, decreasing the total supply
sourcefn burn_from(
&mut self,
params: BurnFromParams,
) -> Result<BurnFromReturn, Self::TokenError>
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.