Permission

Defines C++ API functions for validating authorization of keys and permissions.

Functions

Functions Documentation

function check_transaction_authorization

bool eosio::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
)

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

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

Returns:

1 if the transaction is authorized, 0 otherwise

function check_permission_authorization

bool eosio::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
)

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

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)

Returns:

1 if the permission is authorized, 0 otherwise

function check_transaction_authorization

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

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

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

Returns:

whether the transaction was authorized by provided keys and permissions

function check_permission_authorization

bool eosio::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()}
)

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

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)

Returns:

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

function get_permission_last_used

time_point eosio::get_permission_last_used(
    name account,
    name permission
)

Returns the last used time of a permission

Parameters:

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

Returns:

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

function get_account_creation_time

time_point eosio::get_account_creation_time(
    name account
)

Returns the creation time of an account

Parameters:

  • account - the account

Returns:

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