Skip to main content

Nep17Token

Trait Nep17Token 

Source
pub trait Nep17Token {
    // Required methods
    fn symbol(&self) -> NeoResult<NeoString>;
    fn decimals(&self) -> NeoResult<u8>;
    fn total_supply(&self) -> NeoResult<NeoInteger>;
    fn balance_of(&self, account: &NeoByteString) -> NeoResult<NeoInteger>;
    fn transfer(
        &self,
        from: &NeoByteString,
        to: &NeoByteString,
        amount: &NeoInteger,
        data: &NeoValue,
    ) -> NeoResult<bool>;
}
Expand description

NEP-17 fungible token standard trait.

Contracts implementing this trait are compliant with the NEP-17 token standard, which is the canonical fungible token interface on Neo N3.

Required Methods§

Source

fn symbol(&self) -> NeoResult<NeoString>

Returns the token symbol (e.g. “NEO”, “GAS”).

Source

fn decimals(&self) -> NeoResult<u8>

Returns the number of decimals the token uses.

Source

fn total_supply(&self) -> NeoResult<NeoInteger>

Returns the total token supply.

Source

fn balance_of(&self, account: &NeoByteString) -> NeoResult<NeoInteger>

Returns the token balance of the given account.

Source

fn transfer( &self, from: &NeoByteString, to: &NeoByteString, amount: &NeoInteger, data: &NeoValue, ) -> NeoResult<bool>

Transfers amount tokens from from to to.

The implementation MUST:

  • Verify from witness via check_witness
  • Return false if the balance is insufficient
  • Fire a Transfer event on success
  • Call onNEP17Payment on to if it is a deployed contract

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§