System

Defines wrappers over eosio_assert. More...

Functions

Detailed Description

Defines time related functions and eosio_exit. Defines API for interacting with system level intrinsics.

Functions Documentation

function eosio_assert

void eosio_assert(
    uint32_t test,
    const char * msg
)

Aborts processing of this action and unwinds all pending changes if the test condition is true

Parameters:

  • test - 0 to abort, 1 to ignore

Example:

eosio_assert(1 == 2, "One is not equal to two.");
eosio_assert(1 == 1, "One is not equal to one.");

Parameters:

  • msg - a null terminated string explaining the reason for failure

function eosio_assert_message

void eosio_assert_message(
    uint32_t test,
    const char * msg,
    uint32_t msg_len
)

Aborts processing of this action and unwinds all pending changes if the test condition is true

Parameters:

  • test - 0 to abort, 1 to ignore
  • msg - a pointer to the start of string explaining the reason for failure
  • msg_len - length of the string

function eosio_assert_code

void eosio_assert_code(
    uint32_t test,
    uint64_t code
)

Aborts processing of this action and unwinds all pending changes.

Aborts processing of this action and unwinds all pending changes if the test condition is true

Parameters:

  • test - 0 to abort, 1 to ignore
  • code - the error code

function eosio_exit

void eosio_exit(
    int32_t code
)

This method will abort execution of wasm without failing the contract. This is used to bypass all cleanup / destructors that would normally be called.

Parameters:

  • code - the exit code Example:
eosio_exit(0);
eosio_exit(1);
eosio_exit(2);
eosio_exit(3);

function current_time

uint64_t current_time(
    void 
)

Returns the time in microseconds from 1970 of the current block

Returns:

time in microseconds from 1970 of the current block

function is_feature_activated

bool is_feature_activated(
    const struct capi_checksum256 * feature_digest
)

Check if specified protocol feature has been activated

Parameters:

  • feature_digest - digest of the protocol feature

Returns:

true if the specified protocol feature has been activated, false otherwise

function get_sender

capi_name get_sender(
    void 
)

Return name of account that sent current inline action

Returns:

name of account that sent the current inline action (empty name if not called from inline action)

function eosio_exit

void eosio::eosio_exit(
    int32_t code
)

This method will abort execution of wasm without failing the contract. This is used to bypass all cleanup / destructors that would normally be called.

Parameters:

  • code - the exit code Example:
eosio_exit(0);
eosio_exit(1);
eosio_exit(2);
eosio_exit(3);

function current_time_point

time_point eosio::current_time_point()

Returns the time in microseconds from 1970 of the current block as a time_point

Returns:

time in microseconds from 1970 of the current block as a time_point

function current_block_time

block_timestamp eosio::current_block_time()

Returns the time in microseconds from 1970 of the current block as a block_timestamp

Returns:

time in microseconds from 1970 of the current block as a block_timestamp

function is_feature_activated

bool eosio::is_feature_activated(
    const checksum256 & feature_digest
)

Check if specified protocol feature has been activated

Parameters:

  • feature_digest - digest of the protocol feature

Returns:

true if the specified protocol feature has been activated, false otherwise

function get_sender

name eosio::get_sender()

Return name of account that sent current inline action

Returns:

name of account that sent the current inline action (empty name if not called from inline action)

function check

void eosio::check(
    bool pred,
    std::string_view msg
)

Assert if the predicate fails and use the supplied message. Example:

eosio::check(a == b, "a does not equal b");

function check

void eosio::check(
    bool pred,
    const char * msg
)

Assert if the predicate fails and use the supplied message. Example:

eosio::check(a == b, "a does not equal b");

function check

void eosio::check(
    bool pred,
    const std::string & msg
)

Assert if the predicate fails and use the supplied message. Example:

eosio::check(a == b, "a does not equal b");

function check

void eosio::check(
    bool pred,
    std::string && msg
)

Assert if the predicate fails and use the supplied message. Example:

eosio::check(a == b, "a does not equal b");

function check

void eosio::check(
    bool pred,
    const char * msg,
    size_t n
)

Assert if the predicate fails and use a subset of the supplied message. Example:

const char* msg = "a does not equal b b does not equal a";
eosio::check(a == b, "a does not equal b", 18);

function check

void eosio::check(
    bool pred,
    const std::string & msg,
    size_t n
)

Assert if the predicate fails and use a subset of the supplied message. Example:

std::string msg = "a does not equal b b does not equal a";
eosio::check(a == b, msg, 18);

function check

void eosio::check(
    bool pred,
    uint64_t code
)

Assert if the predicate fails and use the supplied error code. Example:

eosio::check(a == b, 13);