Standard Library

Standard Move VM library is default modules that already developed and developers can use in developing new modules, scripts.

They all placed on the address 0x1. So when you import something from 0x1, you import standard modules, like:

use 0x1::Account;
use 0x1::Event;
use 0x1::XFI;
use 0x1::Coins;
...

You can look for actual standard modules in dvm repository.

Time

Time module allows getting current UNIX timestamp of latest block.

Example:

script {
    use 0x1::Time;

    fun main() {
        let _ = Time::now();
    }
}

The method will return u64 value as UNIX timestamp of the latest block.

Block

Block module allows getting current blockchain height.

The method will return u64 value as the height of the latest block.

Compare

Compare module allows comparing two vectors of u8 values (bytes).

Comparing two-byte vectors:

XFI && Coins

XFI and Coins modules allow to get a type of currency that you going to use in your code.

Oracle

Coins module also contains oracles functions: get price and has price.

More about work with oracles can see in our oracles documentation.

Event

Event module allows us to emit events.

Example with emitting event contains provided number:

Or you you can emit event from your module:

Signer

Signer module allows to work with the signer type. To get address of signer:

Signer type is required for functions which work with resources, address of signer could be useful in case of resource related functions: borrow_global, borrow_global_mut, exists, move_from.

Read more about the signer type in Move Book.

Account

Account module allows to work with user balances: get balances, deposit coins/tokens to balances, withdraw them to deposit in another module, etc.

Also, it creates an account, if the account doesn't exist yet, and related data, like event handlers for sending/receiving payments.

A lot of different methods can be used to send tokens from account A to account B, as these one-line methods:

Also, you can just withdraw from sender balance and deposit to payee:

Or deposit to another module:

Also, get a balance:

For the rest of the features of Account module look at account.move.

Dfinance

Dfinance module allows you to work with coins balances, get coins info, also register new tokens, etc.

First of all, Dfinance module presents type for all balances in the system, it's Dfinance::T:

The value field contains information about actual balance for specific coin/token, e.g.:

Also, you can create an empty coin:

Get denom, decimals, and actual value:

And check if it's user token or system coin:

Also, you can create your resource and make it token too!

And also deposit it to your balance:

More documentation about the feature provided by Dfinance module see in dfinance.move.

Vector

Vector module contains functions to work with vector type.

For example:

Vector module great describe in Move Book.

Signature

Signature module allows to verify ed25519 signature:

Last updated

Was this helpful?