Trait near_contract_tools::standard::nep141::Nep141Controller
source · pub trait Nep141Controller {
Show 13 methods
fn root() -> Slot<()> { ... }
fn slot_account(account_id: &AccountId) -> Slot<u128> { ... }
fn slot_total_supply() -> Slot<u128> { ... }
fn balance_of(account_id: &AccountId) -> u128 { ... }
fn total_supply() -> u128 { ... }
fn withdraw_unchecked(&mut self, account_id: &AccountId, amount: u128) { ... }
fn deposit_unchecked(&mut self, account_id: &AccountId, amount: u128) { ... }
fn transfer_unchecked(
&mut self,
sender_account_id: &AccountId,
receiver_account_id: &AccountId,
amount: u128
) { ... }
fn transfer(
&mut self,
sender_account_id: AccountId,
receiver_account_id: AccountId,
amount: u128,
memo: Option<String>
) { ... }
fn mint(&mut self, account_id: AccountId, amount: u128, memo: Option<String>) { ... }
fn burn(&mut self, account_id: AccountId, amount: u128, memo: Option<String>) { ... }
fn transfer_call(
&mut self,
sender_account_id: AccountId,
receiver_account_id: AccountId,
amount: u128,
memo: Option<String>,
msg: String,
gas_allowance: Gas
) -> Promise { ... }
fn resolve_transfer(
&mut self,
sender_id: AccountId,
receiver_id: AccountId,
amount: u128
) -> u128 { ... }
}
Expand description
Non-public implementations of functions for managing a fungible token.
Provided Methods§
sourcefn slot_account(account_id: &AccountId) -> Slot<u128>
fn slot_account(account_id: &AccountId) -> Slot<u128>
Slot for account data
sourcefn slot_total_supply() -> Slot<u128>
fn slot_total_supply() -> Slot<u128>
Slot for storing total supply
sourcefn balance_of(account_id: &AccountId) -> u128
fn balance_of(account_id: &AccountId) -> u128
Get the balance of an account. Returns 0 if the account does not exist.
sourcefn total_supply() -> u128
fn total_supply() -> u128
Get the total circulating supply of the token.
sourcefn withdraw_unchecked(&mut self, account_id: &AccountId, amount: u128)
fn withdraw_unchecked(&mut self, account_id: &AccountId, amount: u128)
Removes tokens from an account and decreases total supply. No event emission.
Panics
Panics if the current balance of account_id
is less than amount
or
if total_supply
is less than amount
.
sourcefn deposit_unchecked(&mut self, account_id: &AccountId, amount: u128)
fn deposit_unchecked(&mut self, account_id: &AccountId, amount: u128)
Increases the token balance of an account. Updates total supply. No event emission,
Panics
Panics if the balance of account_id
plus amount
>= u128::MAX
, or
if the total supply plus amount
>= u128::MAX
.
sourcefn transfer_unchecked(
&mut self,
sender_account_id: &AccountId,
receiver_account_id: &AccountId,
amount: u128
)
fn transfer_unchecked(
&mut self,
sender_account_id: &AccountId,
receiver_account_id: &AccountId,
amount: u128
)
Decreases the balance of sender_account_id
by amount
and increases
the balance of receiver_account_id
by the same. No change to total
supply. No event emission.
Panics
Panics if the balance of sender_account_id
< amount
or if the
balance of receiver_account_id
plus amount
>= u128::MAX
.
sourcefn transfer(
&mut self,
sender_account_id: AccountId,
receiver_account_id: AccountId,
amount: u128,
memo: Option<String>
)
fn transfer(
&mut self,
sender_account_id: AccountId,
receiver_account_id: AccountId,
amount: u128,
memo: Option<String>
)
Performs an NEP-141 token transfer, with event emission.
Panics
See: Nep141Controller::transfer_unchecked
sourcefn mint(&mut self, account_id: AccountId, amount: u128, memo: Option<String>)
fn mint(&mut self, account_id: AccountId, amount: u128, memo: Option<String>)
Performs an NEP-141 token mint, with event emission.
Panics
See: Nep141Controller::deposit_unchecked
sourcefn burn(&mut self, account_id: AccountId, amount: u128, memo: Option<String>)
fn burn(&mut self, account_id: AccountId, amount: u128, memo: Option<String>)
Performs an NEP-141 token burn, with event emission.
Panics
See: Nep141Controller::withdraw_unchecked
sourcefn transfer_call(
&mut self,
sender_account_id: AccountId,
receiver_account_id: AccountId,
amount: u128,
memo: Option<String>,
msg: String,
gas_allowance: Gas
) -> Promise
fn transfer_call(
&mut self,
sender_account_id: AccountId,
receiver_account_id: AccountId,
amount: u128,
memo: Option<String>,
msg: String,
gas_allowance: Gas
) -> Promise
Performs an NEP-141 token transfer call, with event emission.
Panics
Panics if gas_allowance
< GAS_FOR_FT_TRANSFER_CALL
.
See also: Nep141Controller::transfer