Skip to main content

Module iota::iota

Coin<IOTA> is the token used to pay for gas in IOTA. It has 9 decimals, and the smallest unit (10^-9) is called "nano".

use iota::address; use iota::bag; use iota::balance; use iota::coin; use iota::config; use iota::deny_list; use iota::dynamic_field; use iota::dynamic_object_field; use iota::event; use iota::hex; use iota::object; use iota::transfer; use iota::tx_context; use iota::types; use iota::url; use std::address; use std::ascii; use std::bcs; use std::option; use std::string; use std::type_name; use std::vector;

Module Functions​

pub entry transfer​

public entry fun transfer(c: iota::coin::Coin<iota::iota::IOTA>, recipient: address)

Implementation

public entry fun transfer(c: coin::Coin<IOTA>, recipient: address) {     transfer::public_transfer(c, recipient) }

prv new​

Register the IOTA Coin to acquire IotaTreasuryCap. This should be called only once during genesis creation.

fun new(ctx: &mut iota::tx_context::TxContext): iota::iota::IotaTreasuryCap

Implementation

fun new(ctx: &mut TxContext): IotaTreasuryCap {     assert!(ctx.sender() == @0x0, ENotSystemAddress);     assert!(ctx.epoch() == 0, EAlreadyMinted);     let (treasury, metadata) = coin::create_currency(         IOTA {},         9,         b"IOTA",         b"IOTA",         b"The main (gas)token of the IOTA Network.",         option::some(url::new_unsafe_from_bytes(b"https://iota.org/logo.png")),         ctx,     );     transfer::public_freeze_object(metadata);     IotaTreasuryCap {         inner: treasury,     } }

Structs​

struct IOTA​

Name of the coin

public struct IOTA has drop

Fields

struct IotaTreasuryCap​

The IOTA token treasury capability. Protects the token from unauthorized changes.

public struct IotaTreasuryCap has store

Fields

pub burn​

Destroy the IOTA coin c and decrease the total supply in cap accordingly.

public fun burn(cap: &mut iota::iota::IotaTreasuryCap, c: iota::coin::Coin<iota::iota::IOTA>, ctx: &iota::tx_context::TxContext): u64

Implementation

public fun burn(cap: &mut IotaTreasuryCap, c: Coin<IOTA>, ctx: &TxContext): u64 {     assert!(ctx.sender() == @0x0, ENotSystemAddress);     cap.inner.burn(c) }

pub burn_balance​

Destroy the IOTA balance b and decrease the total supply in cap accordingly.

public fun burn_balance(cap: &mut iota::iota::IotaTreasuryCap, b: iota::balance::Balance<iota::iota::IOTA>, ctx: &iota::tx_context::TxContext): u64

Implementation

public fun burn_balance(cap: &mut IotaTreasuryCap, b: Balance<IOTA>, ctx: &TxContext): u64 {     assert!(ctx.sender() == @0x0, ENotSystemAddress);     cap.inner.supply_mut().decrease_supply(b) }

pub mint​

Create an IOTA coin worth value and increase the total supply in cap accordingly.

public fun mint(cap: &mut iota::iota::IotaTreasuryCap, value: u64, ctx: &mut iota::tx_context::TxContext): iota::coin::Coin<iota::iota::IOTA>

Implementation

public fun mint(cap: &mut IotaTreasuryCap, value: u64, ctx: &mut TxContext): Coin<IOTA> {     assert!(ctx.sender() == @0x0, ENotSystemAddress);     cap.inner.mint(value, ctx) }

pub mint_balance​

Mint some amount of IOTA as a Balance and increase the total supply in cap accordingly. Aborts if value + cap.inner.total_supply >= U64_MAX

public fun mint_balance(cap: &mut iota::iota::IotaTreasuryCap, value: u64, ctx: &iota::tx_context::TxContext): iota::balance::Balance<iota::iota::IOTA>

Implementation

public fun mint_balance(cap: &mut IotaTreasuryCap, value: u64, ctx: &TxContext): Balance<IOTA> {     assert!(ctx.sender() == @0x0, ENotSystemAddress);     cap.inner.mint_balance(value) }

pub total_supply​

Return the total number of IOTA's in circulation.

public fun total_supply(cap: &iota::iota::IotaTreasuryCap): u64

Implementation

public fun total_supply(cap: &IotaTreasuryCap): u64 {     cap.inner.total_supply() }

Constants​

err EAlreadyMinted​

const EAlreadyMinted: u64 = 0;

err ENotSystemAddress​

Sender is not @0x0 the system address.

const ENotSystemAddress: u64 = 1;