Menu

Action

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

Classes

Type Name
struct eosio::permission_level
Packed representation of a permission level (Authorization)
struct eosio::action
Packed representation of an action.
struct eosio::detail::unwrap
struct eosio::detail::unwrap< ignore< T > >
struct eosio::detail::convert
struct eosio::detail::convert< const char * >
struct eosio::detail::convert< char * >
struct eosio::detail::is_same
struct eosio::detail::is_same< bool, U >
struct eosio::detail::is_same< T, bool >
struct eosio::detail::get_nth_impl
struct eosio::detail::get_nth_impl< N, N, Arg, Args... >
struct eosio::detail::get_nth
struct eosio::detail::check_types
struct eosio::detail::check_types< Action, I, T >
struct eosio::action_wrapper
Used to wrap an a particular action to simplify the process of other contracts sending inline actions to "wrapped" action. Example:
struct eosio::variant_action_wrapper
struct eosio::inline_dispatcher
struct eosio::inline_dispatcher< void(T::*)(Args...), Name >

Typedefs

Variables

Functions

Defines

Detailed Description

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

Note:

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

Typedefs Documentation

typedef type

typedef T eosio::detail::unwrap< T >::type;

typedef type

typedef T eosio::detail::unwrap< ignore< T > >::type;

typedef deduced

using eosio::detail::deduced = typedef decltype(get_args(Action));

typedef deduced_nounwrap

using eosio::detail::deduced_nounwrap = typedef decltype(get_args_nounwrap(Action));

typedef type

typedef T eosio::detail::convert< T >::type;

typedef type

typedef std::string eosio::detail::convert< const char * >::type;

typedef type

typedef std::string eosio::detail::convert< char * >::type;

typedef type

using eosio::detail::check_types< Action, I, T, Rest >::type =  check_types<Action, I+1, Rest...>;

Variables Documentation

variable actor

name eosio::permission_level::actor;

Name of the account who owns this permission.

Name of the account who owns this permission

variable permission

name eosio::permission_level::permission;

Name of the permission.

Name of the permission

variable account

name eosio::action::account;

Name of the account the action is intended for.

Name of the account the action is intended for

variable name

name eosio::action::name;

Name of the action.

Name of the action

variable authorization

std::vector< permission_level > eosio::action::authorization;

List of permissions that authorize this action.

List of permissions that authorize this action

variable data

std::vector< char > eosio::action::data;

Payload data.

Payload data

variable value

constexpr bool eosio::detail::is_same< T, U >::value;

variable value

constexpr bool eosio::detail::is_same< bool, U >::value;

variable value

constexpr bool eosio::detail::is_same< T, bool >::value;

variable value

constexpr auto eosio::detail::get_nth_impl< N, I, Arg, Args >::value;

variable value

constexpr auto eosio::detail::get_nth_impl< N, N, Arg, Args... >::value;

variable value

constexpr auto eosio::detail::get_nth< N, Args >::value;

variable value

constexpr bool eosio::detail::check_types< Action, I, T, Rest >::value;

variable value

constexpr bool eosio::detail::check_types< Action, I, T >::value;

variable action_name

static constexpr eosio::name eosio::action_wrapper< Name, Action >::action_name;

variable code_name

eosio::name eosio::action_wrapper< Name, Action >::code_name;

variable permissions

std::vector< eosio::permission_level > eosio::action_wrapper< Name, Action >::permissions;

variable action_name

static constexpr eosio::name eosio::variant_action_wrapper< Name, Actions >::action_name;

variable code_name

eosio::name eosio::variant_action_wrapper< Name, Actions >::code_name;

variable permissions

std::vector< eosio::permission_level > eosio::variant_action_wrapper< Name, Actions >::permissions;

Functions Documentation

function unpack_action_data

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

Interpret the action body as type T.

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
)

Notify an account for this action.

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.

Note:

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

Parameters:

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

Example:

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

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
)

Verify specified account exists in the set of provided auths.

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 permission_level

eosio::permission_level::permission_level(
    name a,
    name p
)

Construct a new permission level object.

Construct a new permission level object with actor name and permission name

Parameters:

  • a - Name of the account who owns this authorization
  • p - Name of the permission

function permission_level

eosio::permission_level::permission_level()

Construct a new permission level object.

Default Constructor

function require_auth

void eosio::require_auth(
    const permission_level & level
)

Require the specified authorization for this action.

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.

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.

Verifies that n is an existing account.

Parameters:

  • n - name of the account to check

function action

eosio::action::action() = default

Construct a new action object.

Default Constructor

function action

template<typename T>
eosio::action::action(
    const permission_level & auth,
    struct name a,
    struct name n,
    T && value
)

Construct a new action object with the given permission, action receiver, action name, action struct.

Construct a new action object with the given action struct

Template parameters:

  • T - Type of action struct, must be serializable by pack(...)

Parameters:

  • auth - The permissions that authorizes this action
  • a - The name of the account this action is intended for (action receiver)
  • n - The name of the action
  • value - The action struct that will be serialized via pack into data

function action

template<typename T>
eosio::action::action(
    std::vector< permission_level > auths,
    struct name a,
    struct name n,
    T && value
)

Construct a new action object with the given list of permissions, action receiver, action name, action struct.

Construct a new action object with the given action struct

Template parameters:

  • T - Type of action struct, must be serializable by pack(...)

Parameters:

  • auths - The list of permissions that authorize this action
  • a - The name of the account this action is intended for (action receiver)
  • n - The name of the action
  • value - The action struct that will be serialized via pack into data

function send

void eosio::action::send() const

Send the action as inline action.

Send the action as inline action

function send_context_free

void eosio::action::send_context_free() const

Send the action as inline context free action.

Send the action as inline context free action

Precondition:

This action should not contain any authorizations

function data_as

template<typename T>
T eosio::action::data_as()

Retrieve the unpacked data as T.

Retrieve the unpacked data as T

Template parameters:

  • T expected type of data

Returns:

the action data

function get_args

template<typename R, typename Act, typename... Args>
auto eosio::detail::get_args(
    R(Act::*)(Args...) p
)

function get_args_nounwrap

template<typename R, typename Act, typename... Args>
auto eosio::detail::get_args_nounwrap(
    R(Act::*)(Args...) p
)

function type_check

template<auto Action, typename... Ts>
constexpr bool eosio::detail::type_check()

function action_wrapper

template<typename Code>
constexpr eosio::action_wrapper< Name, Action >::action_wrapper(
    Code && code,
    std::vector< eosio::permission_level > && perms
)

function action_wrapper

template<typename Code>
constexpr eosio::action_wrapper< Name, Action >::action_wrapper(
    Code && code,
    const std::vector< eosio::permission_level > & perms
)

function action_wrapper

template<typename Code>
constexpr eosio::action_wrapper< Name, Action >::action_wrapper(
    Code && code,
    eosio::permission_level && perm
)

function action_wrapper

template<typename Code>
constexpr eosio::action_wrapper< Name, Action >::action_wrapper(
    Code && code,
    const eosio::permission_level & perm
)

function get_mem_ptr

static static constexpr auto eosio::action_wrapper< Name, Action >::get_mem_ptr()

function to_action

template<typename... Args>
action eosio::action_wrapper< Name, Action >::to_action(
    Args &&... args
) const

function send

template<typename... Args>
void eosio::action_wrapper< Name, Action >::send(
    Args &&... args
) const

function send_context_free

template<typename... Args>
void eosio::action_wrapper< Name, Action >::send_context_free(
    Args &&... args
) const

function variant_action_wrapper

template<typename Code>
constexpr eosio::variant_action_wrapper< Name, Actions >::variant_action_wrapper(
    Code && code,
    std::vector< eosio::permission_level > && perms
)

function variant_action_wrapper

template<typename Code>
constexpr eosio::variant_action_wrapper< Name, Actions >::variant_action_wrapper(
    Code && code,
    const std::vector< eosio::permission_level > & perms
)

function variant_action_wrapper

template<typename Code>
constexpr eosio::variant_action_wrapper< Name, Actions >::variant_action_wrapper(
    Code && code,
    eosio::permission_level && perm
)

function variant_action_wrapper

template<typename Code>
constexpr eosio::variant_action_wrapper< Name, Actions >::variant_action_wrapper(
    Code && code,
    const eosio::permission_level & perm
)

function get_mem_ptr

template<size_t Variant>
static static constexpr auto eosio::variant_action_wrapper< Name, Actions >::get_mem_ptr()

function to_action

template<size_t Variant, typename... Args>
action eosio::variant_action_wrapper< Name, Actions >::to_action(
    Args &&... args
) const

function send

template<size_t Variant, typename... Args>
void eosio::variant_action_wrapper< Name, Actions >::send(
    Args &&... args
) const

function send_context_free

template<size_t Variant, typename... Args>
void eosio::variant_action_wrapper< Name, Actions >::send_context_free(
    Args &&... args
) const

function dispatch_inline

template<typename... Args>
void eosio::dispatch_inline(
    name code,
    name act,
    std::vector< permission_level > perms,
    std::tuple< Args... > args
)

function call

static static void eosio::inline_dispatcher< void(T::*)(Args...), Name >::call(
    name code,
    const permission_level & perm,
    std::tuple< Args... > args
)

function call

static static void eosio::inline_dispatcher< void(T::*)(Args...), Name >::call(
    name code,
    std::vector< permission_level > perms,
    std::tuple< Args... > args
)

function publication_time

time_point eosio::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 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

Defines Documentation

define SEND_INLINE_ACTION

#define SEND_INLINE_ACTION(CONTRACT, NAME, ...)\
INLINE_ACTION_SENDER(std::decay_t<decltype(CONTRACT)>, NAME)( (CONTRACT).get_self(),\
BOOST_PP_TUPLE_ENUM(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__)) );

Send inline action.

Send inline action

Parameters:

  • CONTRACT - The account this action is intended for
  • NAME - The name of the action
  • ... - The member of the action specified as ("action_member1_name", action_member1_value)("action_member2_name", action_member2_value)