Action

Defines type-safe C++ wrappers for querying action and sending action. More...

Classes

Type Name
struct eosio::permission_level
struct eosio::action

Functions

Detailed Description

Note:

There are some methods from the Action that can be used directly from C++

Functions Documentation

function unpack_action_data

template<typename T>
T eosio::unpack_action_data()

Returns:

Unpacked action data casted as T.

Example:

struct dummy_action {
  char a; //1
  unsigned long long b; //8
  int  c; //4

  EOSLIB_SERIALIZE( dummy_action, (a)(b)(c) )
};
dummy_action msg = unpack_action_data<dummy_action>();

function require_recipient

void eosio::require_recipient(
    name notify_account
)

Add the specified account to set of accounts to be notified.

Add the specified account to set of accounts to be notified

Parameters:

  • notify_account - name of the account to be verified

function require_recipient

template<typename... accounts>
void eosio::require_recipient(
    name notify_account,
    accounts... remaining_accounts
)

All of the listed accounts will be added to the set of accounts to be notified This helper method enables you to add multiple accounts to accounts to be notified list with a single call rather than having to call the similar C API multiple times.

Parameters:

  • notify_account account to be notified
  • remaining_accounts accounts to be notified

Note:

action.code is also considered as part of the set of notified accounts

Example:

require_recipient("Account1"_n, "Account2"_n, "Account3"_n); // throws exception if any of them not in set.

function require_auth

void eosio::require_auth(
    name n
)

Verifies that Name exists in the set of provided auths on a action. Fails if not found.

Parameters:

  • name - name of the account to be verified

function publication_time

time_point eosio::publication_time()

Get the publication time.

Returns the time in microseconds from 1970 of the publication_time

Returns:

the time in microseconds from 1970 of the publication_time

function read_action_data

uint32_t eosio::read_action_data(
    void * msg,
    uint32_t len
)

Copy current action data to the specified location.

Copy up to length bytes of current action data to the specified location

Parameters:

  • msg - a pointer where up to length bytes of the current action data will be copied
  • len - len of the current action data to be copied, 0 to report required size

Returns:

the number of bytes copied to msg, or number of bytes that can be copied if len==0 passed

Precondition:

msg is a valid pointer to a range of memory at least len bytes long

Post

msg is filled with packed action data

function require_auth

void eosio::require_auth(
    const permission_level & level
)

Require the specified authorization for this action. If this action doesn't contain the specified auth, it will fail.

Parameters:

  • level - Authorization to be required

function has_auth

bool eosio::has_auth(
    name n
)

Verifies that n has auth.

Parameters:

  • n - name of the account to be verified

function is_account

bool eosio::is_account(
    name n
)

Verifies that n is an existing account.

Parameters:

  • n - name of the account to check