Advertisement
Guest User

WAX RNG sample usage

a guest
May 24th, 2019
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. // This requires CDT 1.6.x or later
  2. #include <eosio/eosio.hpp>
  3.  
  4. #include <string>
  5. #include <tuple>
  6.  
  7. using namespace eosio;
  8.  
  9. CONTRACT sample: public contract {
  10. public:
  11.     WAX_CONTRACT_NAME(name receiver, name code, datastream<const char*> ds)
  12.         : contract(receiver, code, ds) {
  13.     }
  14.  
  15.     ACTION printrand(uint64_t assoc_id, uint64_t signing_value) {
  16.         action(
  17.             { get_self(), "active"_n },
  18.             "orng.wax"_n,
  19.             "requestrand"_n,
  20.             std::tuple{ assoc_id, signing_value, get_self() })
  21.             .send();
  22.     }
  23.  
  24.     /// Called automatically by 'orng.wax' smart contract when the RNG Oracle
  25.     /// has generated the random value. wax.orng, before calling this action,
  26.     /// verifies that the generated random value was signed with the
  27.     /// provided "signing_value"
  28.     ACTION receiverand(uint64_t assoc_id, const std::string& random_value) {
  29.         print_f("Assoc ID = %, Random value = %\n", assoc_id, random_value.c_str());
  30.     }
  31.    
  32. }; // CONTRACT sample
  33.  
  34. EOSIO_DISPATCH(WAX_CONTRACT_NAME, (printrand)(receiverand))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement