Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement STATIC methods for rex_system_initialized & rex_available #130

Closed
Tracked by #128 ...
DenisCarriere opened this issue Apr 17, 2024 · 1 comment
Closed
Tracked by #128 ...
Labels

Comments

@DenisCarriere
Copy link
Contributor

DenisCarriere commented Apr 17, 2024

Methods to expose if REX is available or not.

Needed for contracts that want to implement donatetorex action which require REX to be active.

static bool rex_system_initialized() {
   eosiosystem::rex_pool_table _rexpool( "eosio"_n, "eosio"_n.value );
   return _rexpool.begin() != _rexpool.end();
}

static bool rex_available() {
   eosiosystem::rex_pool_table _rexpool( "eosio"_n, "eosio"_n.value );
   return rex_system_initialized() && _rexpool.begin()->total_rex.amount > 0;
}

Example code

if (rex_available()) {
  eosiosystem::system_contract::donatetorex_action donatetorex( "eosio"_n, { get_self(), "active"_n });
  donatetorex.send(get_self(), quantity, memo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants