Module sui::sui
Coin
use std::address;
use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::type_name;
use std::vector;
use sui::address;
use sui::bag;
use sui::balance;
use sui::coin;
use sui::config;
use sui::deny_list;
use sui::dynamic_field;
use sui::dynamic_object_field;
use sui::event;
use sui::hex;
use sui::object;
use sui::table;
use sui::transfer;
use sui::tx_context;
use sui::types;
use sui::url;
use sui::vec_set;
Struct SUI
Name of the coin
public struct SUI has drop
Click to open
Fields
Constants
const EAlreadyMinted: u64 = 0;
Sender is not @0x0 the system address.
const ENotSystemAddress: u64 = 1;
The amount of Mist per Sui token based on the fact that mist is 10^-9 of a Sui token
const MIST_PER_SUI: u64 = 1000000000;
The total supply of Sui denominated in Mist (10 Billion * 10^9)
const TOTAL_SUPPLY_MIST: u64 = 10000000000000000000;
The total supply of Sui denominated in whole Sui tokens (10 Billion)
const TOTAL_SUPPLY_SUI: u64 = 10000000000;
Function new
Register the SUI Coin to acquire its Supply. This should be called only once during genesis creation.
fun new(ctx: &mut sui::tx_context::TxContext): sui::balance::Balance<sui::sui::SUI>
Click to open
Implementation
fun new(ctx: &mut TxContext): Balance<SUI> {
assert!(ctx.sender() == @0x0, ENotSystemAddress);
assert!(ctx.epoch() == 0, EAlreadyMinted);
let (treasury, metadata) = coin::create_currency(
SUI {},
9,
b"SUI",
b"Sui",
// TODO: add appropriate description and logo url
b"",
option::none(),
ctx,
);
transfer::public_freeze_object(metadata);
let mut supply = treasury.treasury_into_supply();
let total_sui = supply.increase_supply(TOTAL_SUPPLY_MIST);
supply.destroy_supply();
total_sui
}
Function transfer
public entry fun transfer(c: sui::coin::Coin<sui::sui::SUI>, recipient: address)
Click to open
Implementation
public entry fun transfer(c: coin::Coin<SUI>, recipient: address) {
transfer::public_transfer(c, recipient)
}