跳到主要内容

eosio

Namespaces

Name
eosio::_datastream_detail
eosio::_multi_index_detail
eosio::detail
eosio::impl
eosio::internal_use_do_not_use

Classes

Name
structeosio::permission_level
structeosio::action
structeosio::action_wrapper
Used to wrap an a particular action to simplify the process of other contracts sending inline actions to "wrapped" action. Example:
structeosio::variant_action_wrapper
structeosio::inline_dispatcher
structeosio::inline_dispatcher< void(T::*)(Args...), Name >
classeosio::contract
structeosio::const_mem_fun
structeosio::indexed_by
classeosio::multi_index
Defines EOSIO Multi Index Table.
structeosio::blockchain_parameters
structeosio::producer_key
structeosio::producer_schedule
structeosio::key_weight
structeosio::block_signing_authority_v0
weighted threshold multi-sig authority
structeosio::producer_authority
Maps producer with its signing key.
structeosio::security_group
classeosio::singleton
classeosio::transaction_header
Contains details about the transaction.
classeosio::transaction
structeosio::onerror
structeosio::asset
structeosio::extended_asset
classeosio::binary_extension
classeosio::datastream
classeosio::datastream< size_t >
classeosio::fixed_bytes
structeosio::ignore
structeosio::ignore_wrapper
structeosio::name
classeosio::iostream
structeosio::overloaded
classeosio::rope
classeosio::string
classeosio::symbol_code
classeosio::symbol
classeosio::extended_symbol
classeosio::microseconds
classeosio::time_point
classeosio::time_point_sec
classeosio::block_timestamp
structeosio::unsigned_int
structeosio::signed_int

Types

Name
using std::variant< block_signing_authority_v0 >block_signing_authority
using uint32_tblock_num_t
typedef std::tuple< uint16_t, std::vector< char > >extension
typedef std::vector< extension >extensions_type
using std::stringkey_type
typedef block_timestampblock_timestamp_type

Functions

Name
template <typename T >
T
unpack_action_data()
voidrequire_recipient(name notify_account)
Add the specified account to set of accounts to be notified.
template <typename... accounts>
void
require_recipient(name notify_account, accounts... remaining_accounts)
voidrequire_auth(name n)
time_pointpublication_time()
namecurrent_receiver()
uint32_tread_action_data(void * msg, uint32_t len)
uint32_taction_data_size()
voidrequire_auth(const permission_level & level)
boolhas_auth(name n)
boolis_account(name n)
template <typename... Args>
void
dispatch_inline(name code, name act, std::vector< permission_level > perms, std::tuple< Args... > args)
template <typename Contract ,typename FirstAction ,typename SecondAction ,typename... Actions>
bool
dispatch(uint64_t code, uint64_t act)
template <typename T ,typename... Args>
bool
execute_action(name self, name code, void(T::*)(Args...) func)
boolcheck_transaction_authorization(const char trx_data, uint32_t trx_size, const char pubkeys_data, uint32_t pubkeys_size, const char * perms_data, uint32_t perms_size)
boolcheck_permission_authorization(name account, name permission, const char pubkeys_data, uint32_t pubkeys_size, const char perms_data, uint32_t perms_size, microseconds delay)
boolcheck_transaction_authorization(const transaction & trx, const std::set< permission_level > & provided_permissions, const std::set< public_key > & provided_keys =std::set< public_key >())
boolcheck_permission_authorization(name account, name permission, const std::set< public_key > & provided_keys, const std::set< permission_level > & provided_permissions =std::set< permission_level >(), microseconds provided_delay =microseconds{std::numeric_limits< int64_t >::max()})
time_pointget_permission_last_used(name account, name permission)
time_pointget_account_creation_time(name account)
voidset_blockchain_parameters(const eosio::blockchain_parameters & params)
voidget_blockchain_parameters(eosio::blockchain_parameters & params)
voidget_resource_limits(name account, int64_t & ram_bytes, int64_t & net_weight, int64_t & cpu_weight)
voidset_resource_limits(name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight)
std::optional< uint64_t >set_proposed_producers(const std::vector< producer_key > & prods)
std::optional< uint64_t >set_proposed_producers(const std::vector< producer_authority > & prods)
boolis_privileged(name account)
voidset_privileged(name account, bool is_priv)
voidpreactivate_feature(const checksum256 & feature_digest)
std::vector< name >get_active_producers()
int64_tadd_security_group_participants(const std::set< name > & participants)
int64_tremove_security_group_participants(const std::set< name > & participants)
boolin_active_security_group(const std::set< name > & participants)
security_groupget_active_security_group()
voideosio_exit(int32_t code)
time_pointcurrent_time_point()
block_timestampcurrent_block_time()
block_num_tcurrent_block_number()
boolis_feature_activated(const checksum256 & feature_digest)
nameget_sender()
voidsend_deferred(const uint128_t & sender_id, name payer, const char * serialized_transaction, size_t size, bool replace =false)
actionget_action(uint32_t type, uint32_t index)
size_tread_transaction(char * ptr, size_t sz)
intcancel_deferred(const uint128_t & sender_id)
size_ttransaction_size()
inttapos_block_num()
inttapos_block_prefix()
uint32_texpiration()
Gets the expiration of the currently executing transaction.
intget_context_free_data(uint32_t index, char * buff, size_t size)
char *write_decimal(char begin, char end, bool dry_run, uint64_t number, uint8_t num_decimal_places, bool negative)
voidcheck(bool pred, std::string_view msg)
voidcheck(bool pred, const char * msg)
voidcheck(bool pred, const std::string & msg)
voidcheck(bool pred, std::string && msg)
voidcheck(bool pred, const char * msg, size_t n)
voidcheck(bool pred, const std::string & msg, size_t n)
voidcheck(bool pred, uint64_t code)
namecurrent_context_contract()
int32_talt_bn128_add(const char op1, uint32_t op1_len, const char op2, uint32_t op2_len, char * result, uint32_t result_len)
int32_talt_bn128_mul(const char g1, uint32_t g1_len, const char scalar, uint32_t scalar_len, char * result, uint32_t result_len)
int32_talt_bn128_pair(const char * pairs, uint32_t pairs_len)
int32_tmod_exp(const char base, uint32_t base_len, const char exp, uint32_t exp_len, const char mod, uint32_t mod_len, char result, uint32_t result_len)
int32_tblake2_f(uint32_t rounds, const char state, uint32_t state_len, const char msg, uint32_t msg_len, const char t0_offset, uint32_t t0_len, const char t1_offset, uint32_t t1_len, int32_t final, char * result, uint32_t result_len)
eosio::checksum256sha3(const char * data, uint32_t length)
voidassert_sha3(const char * data, uint32_t length, const eosio::checksum256 & hash)
eosio::checksum256keccak(const char * data, uint32_t length)
voidassert_keccak(const char * data, uint32_t length, const eosio::checksum256 & hash)
int32_tk1_recover(const char sig, uint32_t sig_len, const char dig, uint32_t dig_len, char * pub, uint32_t pub_len)
template <typename Stream ,typename T >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::list< T > & l)
template <typename Stream ,typename T >
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::list< T > & l)
template <typename Stream ,typename T >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::deque< T > & d)
template <typename Stream ,typename T >
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::deque< T > & d)
template <typename Stream ,typename... Ts>
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::variant< Ts... > & var)
template <int I,typename Stream ,typename... Ts>
void
deserialize(datastream< Stream > & ds, std::variant< Ts... > & var, int i)
template <typename Stream ,typename... Ts>
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::variant< Ts... > & var)
template <typename Stream ,typename T1 ,typename T2 >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::pair< T1, T2 > & t)
template <typename Stream ,typename T1 ,typename T2 >
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::pair< T1, T2 > & t)
template <typename Stream ,typename T >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::optional< T > & opt)
template <typename Stream ,typename T >
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::optional< T > & opt)
template <typename Stream >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const bool & d)
template <typename Stream >
datastream< Stream > &
operator>>(datastream< Stream > & ds, bool & d)
template <typename Stream >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::string & v)
template <typename Stream >
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::string & v)
template <typename Stream ,typename T ,std::size_t N>
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::array< T, N > & v)
template <typename Stream ,typename T ,std::size_t N>
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::array< T, N > & v)
template <typename Stream ,typename T ,std::enable_if_t< _datastream_detail::is_pointer< T >()> * =nullptr>
datastream< Stream > &
operator>>(datastream< Stream > & ds, T )
Pointer should not be serialized, so this function will always throws an error.
template <typename Stream ,typename T ,std::size_t N,std::enable_if_t<!_datastream_detail::is_primitive< T >() &&!_datastream_detail::is_pointer< T >()> * =nullptr>
datastream< Stream > &
operator<<(datastream< Stream > & ds, const T(&) v[N])
template <typename Stream ,typename T ,std::size_t N,std::enable_if_t<!_datastream_detail::is_primitive< T >() &&!_datastream_detail::is_pointer< T >()> * =nullptr>
datastream< Stream > &
operator>>(datastream< Stream > & ds, T(&) v[N])
template <typename Stream ,typename T ,std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::vector< T > & v)
template <typename Stream ,typename T ,std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::vector< T > & v)
template <typename Stream ,typename T >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::set< T > & s)
template <typename Stream ,typename T >
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::set< T > & s)
template <typename Stream ,typename K ,typename V >
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::map< K, V > & m)
template <typename Stream ,typename K ,typename V >
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::map< K, V > & m)
template <typename Stream ,typename... Args>
datastream< Stream > &
operator<<(datastream< Stream > & ds, const std::tuple< Args... > & t)
template <typename Stream ,typename... Args>
datastream< Stream > &
operator>>(datastream< Stream > & ds, std::tuple< Args... > & t)
template <typename DataStream ,typename T ,std::enable_if_t< std::is_class< T >::value &&_datastream_detail::is_datastream< DataStream >::value > * =nullptr>
DataStream &
operator<<(DataStream & ds, const T & v)
template <typename DataStream ,typename T ,std::enable_if_t< std::is_class< T >::value &&_datastream_detail::is_datastream< DataStream >::value > * =nullptr>
DataStream &
operator>>(DataStream & ds, T & v)
template <typename Stream ,typename T ,std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > &
operator<<(datastream< Stream > & ds, const T & v)
template <typename Stream ,typename T ,std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > &
operator>>(datastream< Stream > & ds, T & v)
template <typename T >
T
unpack(const char * buffer, size_t len)
template <typename T >
void
unpack(T & res, const char * buffer, size_t len)
template <typename T >
T
unpack(const std::vector< char > & bytes)
template <typename T >
size_t
pack_size(const T & value)
template <typename T >
std::vector< char >
pack(const T & value)
template <typename DataStream ,typename T >
DataStream &
operator<<(DataStream & ds, const ::eosio::ignore_wrapper< T > & val)
Serialize ignored_wrapper<T>'s T value.
template <typename DataStream ,typename T >
DataStream &
operator<<(DataStream & ds, const ::eosio::ignore< T > & val)
Serialize an ignored type.
template <typename DataStream ,typename T >
DataStream &
operator>>(DataStream & ds, ::eosio::ignore< T > & )
Deserialize an ignored type.
template <typename T ,typename S >
void
to_key(const T & obj, datastream< S > & stream)
template <int I,typename T ,typename S >
void
to_key_tuple(const T & obj, datastream< S > & stream)
template <typename... Ts,typename S >
void
to_key(const std::tuple< Ts... > & obj, datastream< S > & stream)
template <typename T ,std::size_t N,typename S >
void
to_key(const std::array< T, N > & obj, datastream< S > & stream)
template <typename T ,typename S >
void
to_key_optional(const bool * obj, datastream< S > & stream)
template <typename T ,typename S >
void
to_key_optional(const T * obj, datastream< S > & stream)
template <typename T ,typename U ,typename S >
void
to_key(const std::pair< T, U > & obj, datastream< S > & stream)
template <typename T ,typename S >
void
to_key_range(const T & obj, datastream< S > & stream)
template <typename T ,typename S >
auto
to_key(const T & obj, datastream< S > & stream)
template <typename T ,typename U ,typename S >
void
to_key(const std::map< T, U > & obj, datastream< S > & stream)
template <typename T ,typename S >
void
to_key(const std::optional< T > & obj, datastream< S > & stream)
template <typename S >
void
to_key_varuint32(std::uint32_t obj, datastream< S > & stream)
template <typename S >
void
to_key_varint32(std::int32_t obj, datastream< S > & stream)
template <typename... Ts,typename S >
void
to_key(const std::variant< Ts... > & obj, datastream< S > & stream)
template <std::size_t N,typename S >
void
to_key(const char(&) str[N], datastream< S > & stream)
template <typename S >
void
to_key(std::string_view obj, datastream< S > & stream)
template <typename S >
void
to_key(const std::string & obj, datastream< S > & stream)
template <typename S >
void
to_key(bool obj, datastream< S > & stream)
template <typename UInt ,typename T >
UInt
float_to_key(T value)
template <typename T >
void
convert_to_key(const T & t, key_type & bin)
template <typename T >
key_type
convert_to_key(const T & t)
template <uint8_t Base,typename T =uint64_t>
constexpr T
pow(uint8_t exponent)
voidprinthex(const void * ptr, uint32_t size)
voidprintl(const char * ptr, size_t len)
voidprint(const char * ptr)
template <typename T ,std::enable_if_t< std::is_integral< std::decay_t< T >>::value &&std::is_signed< std::decay_t< T >>::value, int > =0>
void
print(T num)
voidprint(float num)
voidprint(double num)
voidprint(long double num)
template <typename T ,std::enable_if_t<!std::is_integral< std::decay_t< T >>::value, int > =0>
void
print(T && t)
voidprint_f(const char * s)
template <typename Arg ,typename... Args>
void
print_f(const char * s, Arg val, Args... rest)
template <typename Arg ,typename... Args>
void
print(Arg && a, Args &&... args)
template <class... Ts>
overloaded(Ts... )
booloperator<(const string & lhs, const string & rhs)
booloperator>(const string & lhs, const string & rhs)
booloperator<=(const string & lhs, const string & rhs)
booloperator>=(const string & lhs, const string & rhs)
booloperator==(const string & lhs, const string & rhs)
booloperator!=(const string & lhs, const string & rhs)
stringoperator+(const string & lhs, const string & rhs)
template <typename DataStream >
DataStream &
operator<<(DataStream & ds, const string & str)
template <typename DataStream >
DataStream &
operator>>(DataStream & ds, string & str)
template <typename DataStream >
DataStream &
operator<<(DataStream & ds, const eosio::symbol_code sym_code)
template <typename DataStream >
DataStream &
operator>>(DataStream & ds, eosio::symbol_code & sym_code)
template <typename DataStream >
DataStream &
operator<<(DataStream & ds, const eosio::symbol sym)
Serialize a symbol.
template <typename DataStream >
DataStream &
operator>>(DataStream & ds, eosio::symbol & sym)
Deserialize a symbol.
microsecondsseconds(int64_t s)
microsecondsmilliseconds(int64_t s)
microsecondsminutes(int64_t m)
microsecondshours(int64_t h)
microsecondsdays(int64_t d)

Attributes

Name
constexpr static namesame_payer
constexpr autopowers_of_base
iostreamcout

Types Documentation

using block_signing_authority

using eosio::block_signing_authority = typedef std::variant<block_signing_authority_v0>;

variant of all possible block signing authorities

using block_num_t

using eosio::block_num_t = typedef uint32_t;

typedef extension

typedef std::tuple<uint16_t, std::vector<char> > eosio::extension;

typedef extensions_type

typedef std::vector<extension> eosio::extensions_type;

using key_type

using eosio::key_type = typedef std::string;

typedef block_timestamp_type

typedef block_timestamp eosio::block_timestamp_type;

Functions Documentation

function unpack_action_data

template <typename T >
T unpack_action_data()

Return: 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

inline void require_recipient(
name notify_account
)

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

Parameters:

  • notify_account - name of the account to be verified

Add the specified account to set of accounts to be notified

function require_recipient

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

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

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.

Example:

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

function require_auth

inline void require_auth(
name n
)

Parameters:

  • name - name of the account to be verified

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

function publication_time

inline time_point publication_time()

Return: the time in microseconds from 1970 of the publication_time

Returns the time in microseconds from 1970 of the publication_time

function current_receiver

inline name current_receiver()

Return: the account which specifies the current receiver of the action

Get the current receiver of the action

function read_action_data

inline uint32_t read_action_data(
void * msg,
uint32_t len
)

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

Return: 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

Postcondition: msg is filled with packed action data

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

function action_data_size

inline uint32_t action_data_size()

Return: the length of the current action's data field

Get the length of the current action's data field. This method is useful for dynamically sized actions

function require_auth

inline void require_auth(
const permission_level & level
)

Parameters:

  • level - Authorization to be required

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

function has_auth

inline bool has_auth(
name n
)

Parameters:

  • n - name of the account to be verified

Verifies that n has auth.

function is_account

inline bool is_account(
name n
)

Parameters:

  • n - name of the account to check

Verifies that n is an existing account.

function dispatch_inline

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

function dispatch

template <typename Contract ,
typename FirstAction ,
typename SecondAction ,
typename... Actions>
bool dispatch(
uint64_t code,
uint64_t act
)

This method will dynamically dispatch an incoming set of actions to

static Contract::on( ActionType )

For this to work the Actions must be derived from eosio::contract

function execute_action

template <typename T ,
typename... Args>
bool execute_action(
name self,
name code,
void(T::*)(Args...) func
)

Parameters:

  • obj - The contract object that has the correponding action handler
  • func - The action handler

Template Parameters:

  • T - The contract class that has the correponding action handler, this contract should be derived from eosio::contract
  • Q - The namespace of the action handler function
  • Args - The arguments that the action handler accepts, i.e. members of the action

Return: true

Unpack the received action and execute the correponding action handler

function check_transaction_authorization

bool check_transaction_authorization(
const char * trx_data,
uint32_t trx_size,
const char * pubkeys_data,
uint32_t pubkeys_size,
const char * perms_data,
uint32_t perms_size
)

Parameters:

  • trx_data - pointer to the start of the serialized transaction
  • trx_size - size (in bytes) of the serialized transaction
  • pubkeys_data - pointer to the start of the serialized vector of provided public keys
  • pubkeys_size - size (in bytes) of serialized vector of provided public keys (can be 0 if no public keys are to be provided)
  • perms_data - pointer to the start of the serialized vector of provided permissions (empty permission name acts as wildcard)
  • perms_size - size (in bytes) of the serialized vector of provided permissions

Return: 1 if the transaction is authorized, 0 otherwise

Checks if a transaction is authorized by a provided set of keys and permissions

function check_permission_authorization

bool check_permission_authorization(
name account,
name permission,
const char * pubkeys_data,
uint32_t pubkeys_size,
const char * perms_data,
uint32_t perms_size,
microseconds delay
)

Parameters:

  • account - the account owner of the permission
  • permission - the name of the permission to check for authorization
  • pubkeys_data - pointer to the start of the serialized vector of provided public keys
  • pubkeys_size - size (in bytes) of serialized vector of provided public keys (can be 0 if no public keys are to be provided)
  • perms_data - pointer to the start of the serialized vector of provided permissions (empty permission name acts as wildcard)
  • perms_size - size (in bytes) of the serialized vector of provided permissions
  • delay - the provided delay in microseconds (cannot exceed INT64_MAX)

Return: 1 if the permission is authorized, 0 otherwise

Checks if a permission is authorized by a provided delay and a provided set of keys and permissions

function check_transaction_authorization

bool check_transaction_authorization(
const transaction & trx,
const std::set< permission_level > & provided_permissions,
const std::set< public_key > & provided_keys =std::set< public_key >()
)

Parameters:

  • trx - the transaction for which to check authorizations
  • provided_permissions - the set of permissions which have authorized the transaction (empty permission name acts as wildcard)
  • provided_keys - the set of public keys which have authorized the transaction

Return: whether the transaction was authorized by provided keys and permissions

Checks if a transaction is authorized by a provided set of keys and permissions

function check_permission_authorization

bool check_permission_authorization(
name account,
name permission,
const std::set< public_key > & provided_keys,
const std::set< permission_level > & provided_permissions =std::set< permission_level >(),
microseconds provided_delay =microseconds{std::numeric_limits< int64_t >::max()}
)

Parameters:

  • account - the account owner of the permission
  • permission - the permission name to check for authorization
  • provided_keys - the set of public keys which have authorized the transaction
  • provided_permissions - the set of permissions which have authorized the transaction (empty permission name acts as wildcard)
  • provided_delay_us - the provided delay in microseconds (cannot exceed INT64_MAX)

Return: whether the permission was authorized by provided delay, keys, and permissions

Checks if a permission is authorized by a provided delay and a provided set of keys and permissions

function get_permission_last_used

time_point get_permission_last_used(
name account,
name permission
)

Parameters:

  • account - the account owner of the permission
  • permission - the name of the permission

Return: the last used time (in microseconds since Unix epoch) of the permission

Returns the last used time of a permission

function get_account_creation_time

time_point get_account_creation_time(
name account
)

Parameters:

  • account - the account

Return: the creation time (in microseconds since Unix epoch) of the account

Returns the creation time of an account

function set_blockchain_parameters

void set_blockchain_parameters(
const eosio::blockchain_parameters & params
)

Parameters:

  • params - New blockchain parameters to set

Set the blockchain parameters

function get_blockchain_parameters

void get_blockchain_parameters(
eosio::blockchain_parameters & params
)

Parameters:

  • params - It will be replaced with the retrieved blockchain params

Retrieve the blolckchain parameters

function get_resource_limits

inline void get_resource_limits(
name account,
int64_t & ram_bytes,
int64_t & net_weight,
int64_t & cpu_weight
)

Parameters:

  • account - name of the account whose resource limit to get
  • ram_bytes - output to hold retrieved ram limit in absolute bytes
  • net_weight - output to hold net limit
  • cpu_weight - output to hold cpu limit

Get the resource limits of an account

function set_resource_limits

inline void set_resource_limits(
name account,
int64_t ram_bytes,
int64_t net_weight,
int64_t cpu_weight
)

Parameters:

  • account - name of the account whose resource limit to be set
  • ram_bytes - ram limit in absolute bytes
  • net_weight - fractionally proportionate net limit of available resources based on (weight / total_weight_of_all_accounts)
  • cpu_weight - fractionally proportionate cpu limit of available resources based on (weight / total_weight_of_all_accounts)

Set the resource limits of an account

function set_proposed_producers

std::optional< uint64_t > set_proposed_producers(
const std::vector< producer_key > & prods
)

Parameters:

  • producers - vector of producer keys

Return: an optional value of the version of the new proposed schedule if successful

Note: Once the block that contains the proposal becomes irreversible, the schedule is promoted to "pending" automatically. Once the block that promotes the schedule is irreversible, the schedule will become "active"

Proposes a schedule change using the legacy producer key format

function set_proposed_producers

inline std::optional< uint64_t > set_proposed_producers(
const std::vector< producer_authority > & prods
)

Parameters:

  • producers - vector of producer authorities

Return: an optional value of the version of the new proposed schedule if successful

Note: Once the block that contains the proposal becomes irreversible, the schedule is promoted to "pending" automatically. Once the block that promotes the schedule is irreversible, the schedule will become "active"

Proposes a schedule change using the more flexible key format

function is_privileged

inline bool is_privileged(
name account
)

Parameters:

  • account - name of the account to be checked

Return:

  • true if the account is privileged
  • false if the account is not privileged

Check if an account is privileged

function set_privileged

inline void set_privileged(
name account,
bool is_priv
)

Parameters:

  • account - name of the account whose privileged account to be set
  • is_priv - privileged status

Set the privileged status of an account

function preactivate_feature

inline void preactivate_feature(
const checksum256 & feature_digest
)

Parameters:

  • feature_digest - digest of the protocol feature to pre-activate

Pre-activate protocol feature

function get_active_producers

std::vector< name > get_active_producers()

Returns back the list of active producer names.

function add_security_group_participants

inline int64_t add_security_group_participants(
const std::set< name > & participants
)

Parameters:

  • participants - the participants.

Return: -1 if proposing a new security group was unsuccessful, otherwise returns 0.

Propose new participants to the security group.

function remove_security_group_participants

inline int64_t remove_security_group_participants(
const std::set< name > & participants
)

Parameters:

  • participants - the participants. å

Return: -1 if proposing a new security group was unsuccessful, otherwise returns 0.

Propose to remove participants from the security group. å

function in_active_security_group

inline bool in_active_security_group(
const std::set< name > & participants
)

Parameters:

  • participants - the participants.

Return: Returns true if the specified accounts are all in the active security group.

Check if the specified accounts are all in the active security group.

function get_active_security_group

inline security_group get_active_security_group()

Parameters:

  • packed_security_group - the buffer containing the packed security_group.

Return: Returns the size required in the buffer (if the buffer is too small, nothing is written).

Gets the active security group

function eosio_exit

inline void eosio_exit(
int32_t code
)

Parameters:

  • code - the exit code Example:

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

WARNING: this method will immediately abort execution of wasm code that is on the stack and would be executed as the method normally returned. Problems can occur with write-caches, RAII, reference counting when this method aborts execution of wasm code immediately.

eosio_exit(0);
eosio_exit(1);
eosio_exit(2);
eosio_exit(3);

function current_time_point

time_point current_time_point()

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

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

function current_block_time

block_timestamp current_block_time()

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

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

function current_block_number

inline block_num_t current_block_number()

Return: the current block number

Returns the current block number

function is_feature_activated

inline bool is_feature_activated(
const checksum256 & feature_digest
)

Parameters:

  • feature_digest - digest of the protocol feature

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

Check if specified protocol feature has been activated

function get_sender

inline name get_sender()

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

Return name of account that sent current inline action

function send_deferred

inline void send_deferred(
const uint128_t & sender_id,
name payer,
const char * serialized_transaction,
size_t size,
bool replace =false
)

Parameters:

  • sender_id - Account name of the sender of this deferred transaction
  • payer - Account name responsible for paying the RAM for this deferred transaction
  • serialized_transaction - The packed transaction to be deferred
  • size - The size of the packed transaction, required for persistence.
  • replace - If true, will replace an existing transaction.

Send a deferred transaction

function get_action

inline action get_action(
uint32_t type,
uint32_t index
)

Parameters:

  • type - 0 for context free action, 1 for action
  • index - the index of the requested action

Return: the indicated action

Retrieve the indicated action from the active transaction.

function read_transaction

inline size_t read_transaction(
char * ptr,
size_t sz
)

Return: the currently executing transaction

Access a copy of the currently executing transaction.

function cancel_deferred

inline int cancel_deferred(
const uint128_t & sender_id
)

Parameters:

  • sender_id - The id of the sender

Return: 1 if transaction was canceled, 0 if transaction was not found

Precondition:

  • The deferred transaction ID exists.
  • The deferred transaction ID has not yet been published.

Postcondition: Deferred transaction canceled.

Cancels a deferred transaction.

Example:

id = 0xffffffffffffffff
cancel_deferred( id );

function transaction_size

inline size_t transaction_size()

Return: size of the currently executing transaction

Gets the size of the currently executing transaction.

function tapos_block_num

inline int tapos_block_num()

Return: block number used for TAPOS on the currently executing transaction Example:

int tbn = tapos_block_num();

Gets the block number used for TAPOS on the currently executing transaction.

function tapos_block_prefix

inline int tapos_block_prefix()

Return: block prefix used for TAPOS on the currently executing transaction Example:

int tbp = tapos_block_prefix();

Gets the block prefix used for TAPOS on the currently executing transaction.

function expiration

inline uint32_t expiration()

Gets the expiration of the currently executing transaction.

Return: expiration of the currently executing transaction in seconds since Unix epoch

Gets the expiration of the currently executing transaction.

function get_context_free_data

inline int get_context_free_data(
uint32_t index,
char * buff,
size_t size
)

Parameters:

  • index - the index of the context_free_data entry to retrieve
  • buff - output buff of the context_free_data entry
  • size - amount of context_free_data[index] to retrieve into buff, 0 to report required size

Return: size copied, or context_free_data[index].size() if 0 passed for size, or -1 if index not valid

Retrieve the signed_transaction.context_free_data[index].

function write_decimal

char * write_decimal(
char * begin,
char * end,
bool dry_run,
uint64_t number,
uint8_t num_decimal_places,
bool negative
)

function check

inline void 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

inline void 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

inline void 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

inline void 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

inline void 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

inline void 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

inline void check(
bool pred,
uint64_t code
)

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

Example:

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

function current_context_contract

inline name current_context_contract()

function alt_bn128_add

inline int32_t alt_bn128_add(
const char * op1,
uint32_t op1_len,
const char * op2,
uint32_t op2_len,
char * result,
uint32_t result_len
)

Parameters:

  • op1 - operand 1
  • op1_len - size of operand 1
  • op2 - operand 2
  • op2_len - size of operand 2
  • result - result of the addition operation
  • result_len - size of result

Return: -1 if there is an error otherwise 0

Addition operation on the elliptic curve alt_bn128

function alt_bn128_mul

inline int32_t alt_bn128_mul(
const char * g1,
uint32_t g1_len,
const char * scalar,
uint32_t scalar_len,
char * result,
uint32_t result_len
)

Parameters:

  • g1 - G1 point
  • g1_len - size of G1 point
  • scalar - scalar factor
  • scalar_len - size of scalar
  • result - result of the scalar multiplication operation
  • result_len - size of result

Return: -1 if there is an error otherwise 0

Scalar multiplication operation on the elliptic curve alt_bn128

function alt_bn128_pair

inline int32_t alt_bn128_pair(
const char * pairs,
uint32_t pairs_len
)

Parameters:

  • pairs - g1 and g2 pairs
  • pairs_len - size of pairs
  • result - result of the addition operation

Return: -1 if there is an error, 1 if false and 0 if true and successful

Optimal-Ate pairing check elliptic curve alt_bn128

function mod_exp

inline int32_t mod_exp(
const char * base,
uint32_t base_len,
const char * exp,
uint32_t exp_len,
const char * mod,
uint32_t mod_len,
char * result,
uint32_t result_len
)

Parameters:

  • base - base of the exponentiation (BASE)
  • base_len - size of base
  • exp - exponent to raise to that power (EXP)
  • exp_len - size of exp
  • mod - modulus (MOD)
  • mod_len - size of mod
  • result - result of the modular exponentiation
  • result_len - size of result

Return: -1 if there is an error otherwise 0

Big integer modular exponentiation returns an output ( BASE^EXP ) % MOD

function blake2_f

int32_t blake2_f(
uint32_t rounds,
const char * state,
uint32_t state_len,
const char * msg,
uint32_t msg_len,
const char * t0_offset,
uint32_t t0_len,
const char * t1_offset,
uint32_t t1_len,
int32_t final,
char * result,
uint32_t result_len
)

Parameters:

  • rounds - the number of rounds
  • state - state vector
  • state_len - size of state vector
  • msg - message block vector
  • msg_len - size of message block vector
  • t0_offset - offset counters
  • t0_len - size of t0_offset
  • t1_offset - offset counters
  • t1_len - size of t1_offset
  • final - final block flag
  • result - the result of the compression
  • result_len - size of result

Return: -1 if there is an error otherwise 0

BLAKE2 compression function "F" https://eips.ethereum.org/EIPS/eip-152

function sha3

inline eosio::checksum256 sha3(
const char * data,
uint32_t length
)

Parameters:

  • data - data you want to hash
  • length - size of data
  • keccak - whether to use keccak or NIST variant; keccak = 1 and NIST == 0
  • data - Data you want to hash
  • length - Data length

Return:

  • eosio::checksum256 - Computed digest Hashes data using SHA3 NIST.
  • eosio::checksum256 - Computed digest

Hashes data using sha3

function assert_sha3

inline void assert_sha3(
const char * data,
uint32_t length,
const eosio::checksum256 & hash
)

Parameters:

  • data - Data you want to hash
  • length - Data length
  • hash - digest to compare to

Note: !This method is not optimized away during replay

Tests if the SHA3 hash generated from data matches the provided digest.

function keccak

inline eosio::checksum256 keccak(
const char * data,
uint32_t length
)

Parameters:

  • data - Data you want to hash
  • length - Data length

Return: eosio::checksum256 - Computed digest

Hashes data using SHA3 Keccak.

function assert_keccak

inline void assert_keccak(
const char * data,
uint32_t length,
const eosio::checksum256 & hash
)

Parameters:

  • data - Data you want to hash
  • length - Data length
  • hash - digest to compare to

Note: !This method is not optimized away during replay

Tests if the SHA3 keccak hash generated from data matches the provided digest.

function k1_recover

inline int32_t k1_recover(
const char * sig,
uint32_t sig_len,
const char * dig,
uint32_t dig_len,
char * pub,
uint32_t pub_len
)

Parameters:

  • sig - signature.
  • sig_len - size of signature
  • dig - digest of the message that was signed.
  • dig_len - size of digest
  • pub - public key result
  • pub_len - size of public key result

Return: -1 if there was an error 0 otherwise.

Calculates the uncompressed public key used for a given signature on a given digest.

function operator<<

template <typename Stream ,
typename T >
inline datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::list< T > & l
)

Parameters:

  • ds - The stream to write
  • opt - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Serialize an std::list into a stream

function operator>>

template <typename Stream ,
typename T >
inline datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::list< T > & l
)

Parameters:

  • ds - The stream to read
  • opt - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Deserialize an std::list from a stream

function operator<<

template <typename Stream ,
typename T >
inline datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::deque< T > & d
)

Parameters:

  • ds - The stream to write
  • opt - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Serialize an std::deque into a stream

function operator>>

template <typename Stream ,
typename T >
inline datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::deque< T > & d
)

Parameters:

  • ds - The stream to read
  • opt - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Deserialize an std::deque from a stream

function operator<<

template <typename Stream ,
typename... Ts>
inline datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::variant< Ts... > & var
)

Parameters:

  • ds - The stream to write
  • opt - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Serialize an std::variant into a stream

function deserialize

template <int I,
typename Stream ,
typename... Ts>
void deserialize(
datastream< Stream > & ds,
std::variant< Ts... > & var,
int i
)

function operator>>

template <typename Stream ,
typename... Ts>
inline datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::variant< Ts... > & var
)

Parameters:

  • ds - The stream to read
  • opt - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Deserialize an std::variant from a stream

function operator<<

template <typename Stream ,
typename T1 ,
typename T2 >
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::pair< T1, T2 > & t
)

Parameters:

  • ds - The stream to write
  • t - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • Args - Type of the objects contained in the tuple

Return: datastream<Stream>& - Reference to the datastream

Serialize an std::pair

function operator>>

template <typename Stream ,
typename T1 ,
typename T2 >
datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::pair< T1, T2 > & t
)

Parameters:

  • ds - The stream to read
  • t - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer
  • Args - Type of the objects contained in the tuple

Return: datastream<Stream>& - Reference to the datastream

Deserialize an std::pair

function operator<<

template <typename Stream ,
typename T >
inline datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::optional< T > & opt
)

Parameters:

  • ds - The stream to write
  • opt - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Serialize an optional into a stream

function operator>>

template <typename Stream ,
typename T >
inline datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::optional< T > & opt
)

Parameters:

  • ds - The stream to read
  • opt - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Deserialize an optional from a stream

function operator<<

template <typename Stream >
inline datastream< Stream > & operator<<(
datastream< Stream > & ds,
const bool & d
)

Parameters:

  • ds - The stream to read
  • d - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Serialize a bool into a stream

function operator>>

template <typename Stream >
inline datastream< Stream > & operator>>(
datastream< Stream > & ds,
bool & d
)

Parameters:

  • ds - The stream to read
  • d - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Deserialize a bool from a stream

function operator<<

template <typename Stream >
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::string & v
)

Parameters:

  • ds - The stream to write
  • v - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Serialize a string into a stream

function operator>>

template <typename Stream >
datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::string & v
)

Parameters:

  • ds - The stream to read
  • v - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer

Return: datastream<Stream>& - Reference to the datastream

Deserialize a string from a stream

function operator<<

template <typename Stream ,
typename T ,
std::size_t N>
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::array< T, N > & v
)

Parameters:

  • ds - The stream to write
  • v - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the object contained in the array
  • N - Size of the array

Return: datastream<Stream>& - Reference to the datastream

Serialize a fixed size std::array

function operator>>

template <typename Stream ,
typename T ,
std::size_t N>
datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::array< T, N > & v
)

Parameters:

  • ds - The stream to read
  • v - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the object contained in the array
  • N - Size of the array

Return: datastream<Stream>& - Reference to the datastream

Deserialize a fixed size std::array

function operator>>

template <typename Stream ,
typename T ,
std::enable_if_t< _datastream_detail::is_pointer< T >()> * =nullptr>
datastream< Stream > & operator>>(
datastream< Stream > & ds,
T
)

Pointer should not be serialized, so this function will always throws an error.

Parameters:

  • ds - The stream to read

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the pointer

Return: datastream<Stream>& - Reference to the datastream

Postcondition: Throw an exception if it is a pointer

Deserialize a pointer

function operator<<

template <typename Stream ,
typename T ,
std::size_t N,
std::enable_if_t<!_datastream_detail::is_primitive< T >() &&!_datastream_detail::is_pointer< T >()> * =nullptr>
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const T(&) v[N]
)

Parameters:

  • ds - The stream to write
  • v - The value to serialize
  • ds - The stream to write
  • v - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the pointer
  • Stream - Type of datastream buffer
  • T - Type of the pointer

Return:

  • datastream<Stream>& - Reference to the datastream
  • datastream<Stream>& - Reference to the datastream

Serialize a fixed size C array of non-primitive and non-pointer type

Serialize a fixed size C array of primitive type

function operator>>

template <typename Stream ,
typename T ,
std::size_t N,
std::enable_if_t<!_datastream_detail::is_primitive< T >() &&!_datastream_detail::is_pointer< T >()> * =nullptr>
datastream< Stream > & operator>>(
datastream< Stream > & ds,
T(&) v[N]
)

Parameters:

  • ds - The stream to read
  • v - The destination for deserialized value
  • ds - The stream to read
  • v - The destination for deserialized value

Template Parameters:

  • T - Type of the object contained in the array
  • N - Size of the array
  • Stream - Type of datastream buffer
  • T - Type of the object contained in the array
  • N - Size of the array
  • Stream - Type of datastream buffer

Return:

  • datastream<Stream>& - Reference to the datastream
  • datastream<Stream>& - Reference to the datastream

Deserialize a fixed size C array of non-primitive and non-pointer type

Deserialize a fixed size C array of primitive type

function operator<<

template <typename Stream ,
typename T ,
std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::vector< T > & v
)

Parameters:

  • ds - The stream to write
  • v - The value to serialize
  • ds - The stream to write
  • v - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • Stream - Type of datastream buffer
  • T - Type of the object contained in the vector

Return:

  • datastream<Stream>& - Reference to the datastream
  • datastream<Stream>& - Reference to the datastream

Serialize a vector of T, where T is a primitive data type

Serialize a vector

function operator>>

template <typename Stream ,
typename T ,
std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::vector< T > & v
)

Parameters:

  • ds - The stream to read
  • v - The destination for deserialized value
  • ds - The stream to read
  • v - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer
  • Stream - Type of datastream buffer
  • T - Type of the object contained in the vector

Return:

  • datastream<Stream>& - Reference to the datastream
  • datastream<Stream>& - Reference to the datastream

Deserialize a vector of T, where T is a primitive data type

Deserialize a vector

function operator<<

template <typename Stream ,
typename T >
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::set< T > & s
)

Parameters:

  • ds - The stream to write
  • s - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the object contained in the set

Return: datastream<Stream>& - Reference to the datastream

Serialize a set

function operator>>

template <typename Stream ,
typename T >
datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::set< T > & s
)

Parameters:

  • ds - The stream to read
  • s - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the object contained in the set

Return: datastream<Stream>& - Reference to the datastream

Deserialize a set

function operator<<

template <typename Stream ,
typename K ,
typename V >
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::map< K, V > & m
)

Parameters:

  • ds - The stream to write
  • m - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • K - Type of the key contained in the map
  • V - Type of the value contained in the map

Return: datastream<Stream>& - Reference to the datastream

Serialize a map

function operator>>

template <typename Stream ,
typename K ,
typename V >
datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::map< K, V > & m
)

Parameters:

  • ds - The stream to read
  • m - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer
  • K - Type of the key contained in the map
  • V - Type of the value contained in the map

Return: datastream<Stream>& - Reference to the datastream

Deserialize a map

function operator<<

template <typename Stream ,
typename... Args>
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const std::tuple< Args... > & t
)

Parameters:

  • ds - The stream to write
  • t - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • Args - Type of the objects contained in the tuple

Return: datastream<Stream>& - Reference to the datastream

Serialize a tuple

function operator>>

template <typename Stream ,
typename... Args>
datastream< Stream > & operator>>(
datastream< Stream > & ds,
std::tuple< Args... > & t
)

Parameters:

  • ds - The stream to read
  • t - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer
  • Args - Type of the objects contained in the tuple

Return: datastream<Stream>& - Reference to the datastream

Deserialize a tuple

function operator<<

template <typename DataStream ,
typename T ,
std::enable_if_t< std::is_class< T >::value &&_datastream_detail::is_datastream< DataStream >::value > * =nullptr>
DataStream & operator<<(
DataStream & ds,
const T & v
)

Parameters:

  • ds - The stream to write
  • v - The value to serialize

Template Parameters:

  • DataStream - Type of datastream
  • T - Type of class

Return: DataStream& - Reference to the datastream

Serialize a class

function operator>>

template <typename DataStream ,
typename T ,
std::enable_if_t< std::is_class< T >::value &&_datastream_detail::is_datastream< DataStream >::value > * =nullptr>
DataStream & operator>>(
DataStream & ds,
T & v
)

Parameters:

  • ds - The stream to read
  • v - The destination for deserialized value

Template Parameters:

  • DataStream - Type of datastream
  • T - Type of class

Return: DataStream& - Reference to the datastream

Deserialize a class

function operator<<

template <typename Stream ,
typename T ,
std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > & operator<<(
datastream< Stream > & ds,
const T & v
)

Parameters:

  • ds - The stream to write
  • v - The value to serialize

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the primitive type

Return: datastream<Stream>& - Reference to the datastream

Serialize a primitive type

function operator>>

template <typename Stream ,
typename T ,
std::enable_if_t< _datastream_detail::is_primitive< T >()> * =nullptr>
datastream< Stream > & operator>>(
datastream< Stream > & ds,
T & v
)

Parameters:

  • ds - The stream to read
  • v - The destination for deserialized value

Template Parameters:

  • Stream - Type of datastream buffer
  • T - Type of the primitive type

Return: datastream<Stream>& - Reference to the datastream

Deserialize a primitive type

function unpack

template <typename T >
T unpack(
const char * buffer,
size_t len
)

Parameters:

  • buffer - Pointer to the buffer
  • len - Length of the buffer

Template Parameters:

  • T - Type of the unpacked data

Return: T - The unpacked data

Unpack data inside a fixed size buffer as T

function unpack

template <typename T >
void unpack(
T & res,
const char * buffer,
size_t len
)

Parameters:

  • res - Variable to fill with the unpacking
  • buffer - Pointer to the buffer
  • len - Length of the buffer

Template Parameters:

  • T - Type of the unpacked data

Return: T - The unpacked data

Unpack data inside a fixed size buffer as T

function unpack

template <typename T >
T unpack(
const std::vector< char > & bytes
)

Parameters:

  • bytes - Buffer

Template Parameters:

  • T - Type of the unpacked data

Return: T - The unpacked data

Unpack data inside a variable size buffer as T

function pack_size

template <typename T >
size_t pack_size(
const T & value
)

Parameters:

  • value - Data to be packed

Template Parameters:

  • T - Type of the data to be packed

Return: size_t - Size of the packed data

Get the size of the packed data

function pack

template <typename T >
std::vector< char > pack(
const T & value
)

Parameters:

  • value - Data to be packed

Template Parameters:

  • T - Type of the data to be packed

Return: bytes - The packed data

Get packed data

function operator<<

template <typename DataStream ,
typename T >
inline DataStream & operator<<(
DataStream & ds,
const ::eosio::ignore_wrapper< T > & val
)

Serialize ignored_wrapper<T>'s T value.

Parameters:

  • ds - The stream to write
  • val - The value to serialize

Template Parameters:

  • DataStream - Type of datastream buffer

Return: DataStream& - Reference to the datastream

Serialize an ignored_wrapper type into a stream

function operator<<

template <typename DataStream ,
typename T >
inline DataStream & operator<<(
DataStream & ds,
const ::eosio::ignore< T > & val
)

Serialize an ignored type.

Parameters:

  • ds - The stream to write
  • ignore - The value to serialize

Template Parameters:

  • DataStream - Type of datastream buffer

Return: DataStream& - Reference to the datastream

Serialize an ignored type into a stream

function operator>>

template <typename DataStream ,
typename T >
inline DataStream & operator>>(
DataStream & ds,
::eosio::ignore< T > &
)

Deserialize an ignored type.

Parameters:

  • ds - The stream to read
  • ignored - The destination for deserialized value

Template Parameters:

  • DataStream - Type of datastream buffer

Return: DataStream& - Reference to the datastream

Deserialize an ignored type from a stream

function to_key

template <typename T ,
typename S >
void to_key(
const T & obj,
datastream< S > & stream
)

function to_key_tuple

template <int I,
typename T ,
typename S >
void to_key_tuple(
const T & obj,
datastream< S > & stream
)

function to_key

template <typename... Ts,
typename S >
void to_key(
const std::tuple< Ts... > & obj,
datastream< S > & stream
)

function to_key

template <typename T ,
std::size_t N,
typename S >
void to_key(
const std::array< T, N > & obj,
datastream< S > & stream
)

function to_key_optional

template <typename T ,
typename S >
void to_key_optional(
const bool * obj,
datastream< S > & stream
)

function to_key_optional

template <typename T ,
typename S >
void to_key_optional(
const T * obj,
datastream< S > & stream
)

function to_key

template <typename T ,
typename U ,
typename S >
void to_key(
const std::pair< T, U > & obj,
datastream< S > & stream
)

function to_key_range

template <typename T ,
typename S >
void to_key_range(
const T & obj,
datastream< S > & stream
)

function to_key

template <typename T ,
typename S >
auto to_key(
const T & obj,
datastream< S > & stream
)

function to_key

template <typename T ,
typename U ,
typename S >
void to_key(
const std::map< T, U > & obj,
datastream< S > & stream
)

function to_key

template <typename T ,
typename S >
void to_key(
const std::optional< T > & obj,
datastream< S > & stream
)

function to_key_varuint32

template <typename S >
void to_key_varuint32(
std::uint32_t obj,
datastream< S > & stream
)

function to_key_varint32

template <typename S >
void to_key_varint32(
std::int32_t obj,
datastream< S > & stream
)

function to_key

template <typename... Ts,
typename S >
void to_key(
const std::variant< Ts... > & obj,
datastream< S > & stream
)

function to_key

template <std::size_t N,
typename S >
void to_key(
const char(&) str[N],
datastream< S > & stream
)

function to_key

template <typename S >
void to_key(
std::string_view obj,
datastream< S > & stream
)

function to_key

template <typename S >
void to_key(
const std::string & obj,
datastream< S > & stream
)

function to_key

template <typename S >
void to_key(
bool obj,
datastream< S > & stream
)

function float_to_key

template <typename UInt ,
typename T >
UInt float_to_key(
T value
)

function convert_to_key

template <typename T >
void convert_to_key(
const T & t,
key_type & bin
)

function convert_to_key

template <typename T >
key_type convert_to_key(
const T & t
)

function pow

template <uint8_t Base,
typename T =uint64_t>
constexpr T pow(
uint8_t exponent
)

Return: Base^exponent

function printhex

inline void printhex(
const void * ptr,
uint32_t size
)

Parameters:

  • ptr - pointer to bytes of interest
  • size - number of bytes to print

Prints a block of bytes in hexadecimal

function printl

inline void printl(
const char * ptr,
size_t len
)

Parameters:

  • ptr - a string
  • len - number of chars to print

Prints string to a given length

function print

inline void print(
const char * ptr
)

Parameters:

  • ptr - a null terminated string

Prints string

function print

template <typename T ,
std::enable_if_t< std::is_integral< std::decay_t< T >>::value &&std::is_signed< std::decay_t< T >>::value, int > =0>
inline void print(
T num
)

Parameters:

  • num to be printed
  • num to be printed

Prints 8-128 bit signed integer

Prints 8-128 bit unsigned integer

function print

inline void print(
float num
)

Parameters:

  • num to be printed

Prints single-precision floating point number (i.e. float)

function print

inline void print(
double num
)

Parameters:

  • num to be printed

Prints double-precision floating point number (i.e. double)

function print

inline void print(
long double num
)

Parameters:

  • num to be printed

Prints quadruple-precision floating point number (i.e. long double)

function print

template <typename T ,
std::enable_if_t<!std::is_integral< std::decay_t< T >>::value, int > =0>
inline void print(
T && t
)

Parameters:

  • t to be printed

Precondition: T must implements print() function

Prints class object

function print_f

inline void print_f(
const char * s
)

Parameters:

  • s null terminated string to be printed

Prints null terminated string

function print_f

template <typename Arg ,
typename... Args>
inline void print_f(
const char * s,
Arg val,
Args... rest
)

Parameters:

  • s - Null terminated string with to be printed (it can contains format specifier)
  • val - The value used to replace the format specifier
  • rest - The values used to replace the format specifier

Template Parameters:

  • Arg - Type of the value used to replace the format specifier
  • Args - Type of the value used to replace the format specifier

Prints formatted string. It behaves similar to C printf/

Example:

print_f("Number of apples: %", 10);

function print

template <typename Arg ,
typename... Args>
void print(
Arg && a,
Args &&... args
)

Parameters:

  • a - The value to be printed
  • args - The other values to be printed

Template Parameters:

  • Arg - Type of the value used to replace the format specifier
  • Args - Type of the value used to replace the format specifier

Print out value / list of values

Example:

const char *s = "Hello World!";
uint64_t unsigned_64_bit_int = 1e+18;
uint128_t unsigned_128_bit_int (87654323456);
uint64_t string_as_unsigned_64_bit = "abcde"_n;
print(s , unsigned_64_bit_int, unsigned_128_bit_int, string_as_unsigned_64_bit);
// Ouput: Hello World!100000000000000000087654323456abcde

function overloaded

template <class... Ts>
overloaded(
Ts...
)

function operator<

inline bool operator<(
const string & lhs,
const string & rhs
)

function operator>

inline bool operator>(
const string & lhs,
const string & rhs
)

function operator<=

inline bool operator<=(
const string & lhs,
const string & rhs
)

function operator>=

inline bool operator>=(
const string & lhs,
const string & rhs
)

function operator==

inline bool operator==(
const string & lhs,
const string & rhs
)

function operator!=

inline bool operator!=(
const string & lhs,
const string & rhs
)

function operator+

inline string operator+(
const string & lhs,
const string & rhs
)

function operator<<

template <typename DataStream >
DataStream & operator<<(
DataStream & ds,
const string & str
)

function operator>>

template <typename DataStream >
DataStream & operator>>(
DataStream & ds,
string & str
)

function operator<<

template <typename DataStream >
inline DataStream & operator<<(
DataStream & ds,
const eosio::symbol_code sym_code
)

Parameters:

  • ds - The stream to write
  • sym - The value to serialize

Template Parameters:

  • DataStream - Type of datastream buffer

Return: DataStream& - Reference to the datastream

Serialize a symbol_code into a stream

function operator>>

template <typename DataStream >
inline DataStream & operator>>(
DataStream & ds,
eosio::symbol_code & sym_code
)

Parameters:

  • ds - The stream to read
  • symbol - The destination for deserialized value

Template Parameters:

  • DataStream - Type of datastream buffer

Return: DataStream& - Reference to the datastream

Deserialize a symbol_code from a stream

function operator<<

template <typename DataStream >
inline DataStream & operator<<(
DataStream & ds,
const eosio::symbol sym
)

Serialize a symbol.

Parameters:

  • ds - The stream to write
  • sym - The value to serialize

Template Parameters:

  • DataStream - Type of datastream buffer

Return: DataStream& - Reference to the datastream

Serialize a symbol into a stream

function operator>>

template <typename DataStream >
inline DataStream & operator>>(
DataStream & ds,
eosio::symbol & sym
)

Deserialize a symbol.

Parameters:

  • ds - The stream to read
  • symbol - The destination for deserialized value

Template Parameters:

  • DataStream - Type of datastream buffer

Return: DataStream& - Reference to the datastream

Deserialize a symbol from a stream

function seconds

inline microseconds seconds(
int64_t s
)

function milliseconds

inline microseconds milliseconds(
int64_t s
)

function minutes

inline microseconds minutes(
int64_t m
)

function hours

inline microseconds hours(
int64_t h
)

function days

inline microseconds days(
int64_t d
)

Attributes Documentation

variable same_payer

static constexpr static name same_payer {};

variable powers_of_base

constexpr auto powers_of_base = detail::generate_array<detail::largest_power<T, Base>::exponent + 1>( detail::pow_generator<T, Base> );

variable cout

static iostream cout;

Updated on 2022-12-05 at 15:38:07 +0000