ckb_ssri_std::public_module_traits::udt

Trait UDT

Source
pub trait UDT {
    type Error;

    // Required methods
    fn transfer(
        tx: Option<Transaction>,
        to_lock_vec: Vec<Script>,
        to_amount_vec: Vec<u128>,
    ) -> Result<Transaction, Self::Error>;
    fn verify_transfer() -> Result<(), Self::Error>;
    fn name() -> Result<Bytes, Self::Error>;
    fn symbol() -> Result<Bytes, Self::Error>;
    fn decimals() -> Result<u8, Self::Error>;
    fn icon() -> Result<Bytes, Self::Error>;
    fn mint(
        tx: Option<Transaction>,
        to_lock_vec: Vec<Script>,
        to_amount_vec: Vec<u128>,
    ) -> Result<Transaction, Self::Error>;
    fn verify_mint() -> Result<(), Self::Error>;
}
Expand description

User-Defined Token (UDT) trait for implementing custom tokens on CKB

This trait defines the standard interface for implementing fungible tokens on the CKB blockchain following the SSRI protocol.

§Implementation Notes

  • All amounts are represented as u128 in convention
  • Methods that modify state return a Transaction that must be committed
  • Verification methods are separate from state-changing methods

§Example

use ckb_ssri_std::public_module_traits::udt::UDT;

struct MyToken;

impl UDT for MyToken {
    type Error = ();
     
    fn balance() -> Result<u128, Self::Error> {
        // Implementation
        Ok(0)
    }
    // ... implement other required methods
}

Required Associated Types§

Required Methods§

Source

fn transfer( tx: Option<Transaction>, to_lock_vec: Vec<Script>, to_amount_vec: Vec<u128>, ) -> Result<Transaction, Self::Error>

Source

fn verify_transfer() -> Result<(), Self::Error>

Source

fn name() -> Result<Bytes, Self::Error>

Source

fn symbol() -> Result<Bytes, Self::Error>

Source

fn decimals() -> Result<u8, Self::Error>

Source

fn icon() -> Result<Bytes, Self::Error>

Source

fn mint( tx: Option<Transaction>, to_lock_vec: Vec<Script>, to_amount_vec: Vec<u128>, ) -> Result<Transaction, Self::Error>

Source

fn verify_mint() -> Result<(), Self::Error>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§