Test Your WAX RNG Contract

To test your RNG smart contract, you’ll need to use two random, unique numbers. One for your internal customer id and one for the signing_value provided by the user on the client-side.

In this example, we’ll use the following parameters:

Parameter Example Description
customer_id 1267 Required uint64_t. Your internal database id for the customer.
signing_value 445896213 Required uint64_t. A pseudo-random number generated client-side.

Get a Random Number

From the command line, use the cleos push action command to call the getrandom action.

cleos -u https://chain.wax.io push action waxrng getrandom '["waxrng", 1267, 445896213]' -p [email protected]

The console prints the following:

executed transaction: bcf8ec6e2c3c03187c754c76ba455018f65960545020201b6e18ac9b8043935d  120 bytes  12299 us
#  waxrng <= waxrng::getrandom    {"nm":"waxrng","customer_id":1267,"signing_value":445896213}
#      orng.wax <= orng.wax::requestrand        {"assoc_id":1267,"signing_value":445896213,"caller":"waxrng"}
warning: transaction executed locally, but may not be confirmed by the network yet         ]

If the customer’s signing_value has been used by the WAX RNG Service, you’ll receive the following message:

Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: Signing value already used
pending console output:

Verify Your Random Number

The callback function saves your random number to the rngcustomers table. To display the table values, use the cleos get table command.

cleos -u https://chain.wax.io get table waxrng waxrng rngcustomers

The console prints the following JSON results, including the random_value returned from the WAX RNG service and the finalnumber derived from the random_value:

  "rows": [{
      "nm": "waxrngstagng",
      "customer_id": 1267,
      "random_value": "706eb301c6f7673e235c5f386a965057b682175607c4928850c0073a3cdbc4de",
      "finalnumber": 82
  "more": false

What's Next