Menu

struct eosio::asset

Class List > eosio :: asset

Public Attributes

Type Name
int64_t amount
symbol symbol

Public Static Attributes

Type Name
static constexpr int64_t max_amount

Public Functions

Type Name
asset ()
asset (int64_t a, class symbol s)
bool is_amount_within_range () const
bool is_valid () const
void set_amount (int64_t a)
asset operator- () const
asset & operator-= (const asset & a)
asset & operator+= (const asset & a)
asset & operator*= (int64_t a)
Multiplication assignment operator, with a number.
asset & operator/= (int64_t a)
Division assignment operator, with a number.
std::string to_string () const
asset to std::string
void print () const
Print the asset

Friends

Type Name
friend asset operator+
friend asset operator-
friend asset operator*
Multiplication operator, with a number proceeding.
friend asset operator*
friend asset operator/
friend int64_t operator/
friend bool operator==
friend bool operator!=
friend bool operator<
friend bool operator<=
friend bool operator>
friend bool operator>=
friend DataStream & operator<<
friend DataStream & operator>>

Public Attributes Documentation

variable amount

int64_t eosio::asset::amount;

The amount of the asset

variable symbol

symbol eosio::asset::symbol;

The symbol name of the asset

Public Static Attributes Documentation

variable max_amount

constexpr int64_t eosio::asset::max_amount;

Maximum amount possible for this asset. It's capped to 2^62 - 1

Public Functions Documentation

function asset (1/2)

eosio::asset::asset()

function asset (2/2)

eosio::asset::asset(
    int64_t a,
    class symbol s
)

Construct a new asset given the symbol name and the amount

Parameters:

  • a - The amount of the asset
  • s - The name of the symbol

function is_amount_within_range

bool eosio::asset::is_amount_within_range() const

Check if the amount doesn't exceed the max amount

Returns:

true - if the amount doesn't exceed the max amount

Returns:

false - otherwise

function is_valid

bool eosio::asset::is_valid() const

Check if the asset is valid. A valid asset has its amount <= max_amount and its symbol name valid

Returns:

true - if the asset is valid

Returns:

false - otherwise

function set_amount

void eosio::asset::set_amount(
    int64_t a
)

Set the amount of the asset

Parameters:

  • a - New amount for the asset

function operator- (1/2)

asset eosio::asset::operator-() const

Unary minus operator

Returns:

asset - New asset with its amount is the negative amount of this asset

function operator-=

asset& eosio::asset::operator-=(
    const asset & a
)

Subtraction assignment operator

Parameters:

  • a - Another asset to subtract this asset with

Returns:

asset& - Reference to this asset

Post

The amount of this asset is subtracted by the amount of asset a

function operator+=

asset& eosio::asset::operator+=(
    const asset & a
)

Addition Assignment operator

Parameters:

  • a - Another asset to subtract this asset with

Returns:

asset& - Reference to this asset

Post

The amount of this asset is added with the amount of asset a

function operator*=

asset& eosio::asset::operator*=(
    int64_t a
)

Multiplication assignment operator, with a number.

Multiplication assignment operator. Multiply the amount of this asset with a number and then assign the value to itself.

Parameters:

  • a - The multiplier for the asset's amount

Returns:

asset - Reference to this asset

Post

The amount of this asset is multiplied by a

function operator/=

asset& eosio::asset::operator/=(
    int64_t a
)

Division assignment operator, with a number.

Division assignment operator. Divide the amount of this asset with a number and then assign the value to itself.

Parameters:

  • a - The divisor for the asset's amount

Returns:

asset - Reference to this asset

Post

The amount of this asset is divided by a

function to_string

std::string eosio::asset::to_string() const

asset to std::string

asset to std::string

function print

void eosio::asset::print() const

Print the asset

Print the asset

Friends Documentation

friend operator+

asset operator+(
    const asset & a,
    const asset & b
)

Addition operator

Parameters:

  • a - The first asset to be added
  • b - The second asset to be added

Returns:

asset - New asset as the result of addition

friend operator- (2/2)

asset operator-(
    const asset & a,
    const asset & b
)

Subtraction operator

Parameters:

  • a - The asset to be subtracted
  • b - The asset used to subtract

Returns:

asset - New asset as the result of subtraction of a with b

friend operator* (1/2)

asset operator*(
    const asset & a,
    int64_t b
)

Multiplication operator, with a number proceeding.

Multiplication operator, with a number proceeding

Parameters:

  • a - The asset to be multiplied
  • b - The multiplier for the asset's amount

Returns:

asset - New asset as the result of multiplication

friend operator* (2/2)

asset operator*(
    int64_t b,
    const asset & a
)

Multiplication operator, with a number preceeding

Parameters:

  • a - The multiplier for the asset's amount
  • b - The asset to be multiplied

Returns:

asset - New asset as the result of multiplication

friend operator/ (1/2)

asset operator/(
    const asset & a,
    int64_t b
)

Division operator, with a number proceeding

Parameters:

  • a - The asset to be divided
  • b - The divisor for the asset's amount

Returns:

asset - New asset as the result of division

friend operator/ (2/2)

int64_t operator/(
    const asset & a,
    const asset & b
)

Division operator, with another asset

Parameters:

  • a - The asset which amount acts as the dividend
  • b - The asset which amount acts as the divisor

Returns:

int64_t - the resulted amount after the division

Precondition:

Both asset must have the same symbol

friend operator==

bool operator==(
    const asset & a,
    const asset & b
)

Equality operator

Parameters:

  • a - The first asset to be compared
  • b - The second asset to be compared

Returns:

true - if both asset has the same amount

Returns:

false - otherwise

Precondition:

Both asset must have the same symbol

friend operator!=

bool operator!=(
    const asset & a,
    const asset & b
)

Inequality operator

Parameters:

  • a - The first asset to be compared
  • b - The second asset to be compared

Returns:

true - if both asset doesn't have the same amount

Returns:

false - otherwise

Precondition:

Both asset must have the same symbol

friend operator<

bool operator<(
    const asset & a,
    const asset & b
)

Less than operator

Parameters:

  • a - The first asset to be compared
  • b - The second asset to be compared

Returns:

true - if the first asset's amount is less than the second asset amount

Returns:

false - otherwise

Precondition:

Both asset must have the same symbol

friend operator<=

bool operator<=(
    const asset & a,
    const asset & b
)

Less or equal to operator

Parameters:

  • a - The first asset to be compared
  • b - The second asset to be compared

Returns:

true - if the first asset's amount is less or equal to the second asset amount

Returns:

false - otherwise

Precondition:

Both asset must have the same symbol

friend operator>

bool operator>(
    const asset & a,
    const asset & b
)

Greater than operator

Parameters:

  • a - The first asset to be compared
  • b - The second asset to be compared

Returns:

true - if the first asset's amount is greater than the second asset amount

Returns:

false - otherwise

Precondition:

Both asset must have the same symbol

friend operator>=

bool operator>=(
    const asset & a,
    const asset & b
)

Greater or equal to operator

Parameters:

  • a - The first asset to be compared
  • b - The second asset to be compared

Returns:

true - if the first asset's amount is greater or equal to the second asset amount

Returns:

false - otherwise

Precondition:

Both asset must have the same symbol

friend operator<<

template<typename DataStream>
DataStream& operator<<(
    DataStream & ds,
    const asset & t
)

friend operator>>

template<typename DataStream>
DataStream& operator>>(
    DataStream & ds,
    asset & t
)

The documentation for this class was generated from the following file: libraries/eosiolib/asset.hpp