📂 How to Guides

# QRNG Example Project

Table of Contents

The qrng-example (opens new window) project (GitHub repo) demonstrates how to build a smart contract (known as a requester) using the Airnode request–response protocol to receive QRNG services. It is recommended to run the example project to learn how it uses the QRNG service on a testnet, and read the associated README file. It also contains example code that will be useful when creating a requester (smart contract) that requests a random number.

  • qrng-example/contracts/ (opens new window)
    • QrngExamples.sol: A sample requester used to call the QRNG service.
  • qrng-example/deploy/ (opens new window)
    • deploy.js: Script that deploys a requester to a chain.
    • setup.js: Script that sets the parameters on the requester contract. These parameters are used when calling the QRNG service.
    • fund.js: Script that funds the wallet the requester uses to pay the gas costs.

Gas Costs

Using the QRNG service is free, meaning there is no subscription fee to pay. There is a gas cost incurred on-chain when Airnode places the random number on-chain in response to a request, which the requester needs to pay for.

The QRNG example project sets the sponsor wallet (opens new window) using the requester address. The wallet is then used to pay gas costs when the Airnode responds to a request. An alternate method is to use the Admin CLI as is the case with the Remix Example Project.

Designated Sponsor Wallets

Sponsors should not fund a sponsorWallet with more then they can trust the Airnode with, as the Airnode controls the private key to the sponsorWallet. The deployer of such Airnode undertakes no custody obligations, and the risk of loss or misuse of any excess funds sent to the sponsorWallet remains with the sponsor.

Last Updated: 8/9/2022, 3:28:25 PM