Back to Blog

March 24, 2026

A Random Number Generator API for Secure Application Randomness

How developers can request secure random hashes using the Kurier RNG service for games, marketplaces, and distributed applications.

A Random Number Generator API for Secure Application Randomness

Modern applications rely on randomness more than most developers realize.

Games need fair outcomes. Platforms need unbiased selection. Security systems require unpredictable values.

But generating reliable randomness is harder than it looks.

Many applications rely on basic pseudo-random functions like Math.random(). These are fast, but they are not designed for systems where fairness, unpredictability, or security matters. In environments where outcomes must be trusted, developers often need stronger guarantees.

The Kurier RNG API provides a simple way for applications and smart contracts to request secure randomness using a random number generator API built for distributed systems.

Instead of generating randomness locally, applications request a random hash through the Kurier oracle service. The request is processed through a coordinated oracle workflow and the result is delivered back to the requesting system.

This approach allows developers to integrate reliable randomness into their applications without building custom infrastructure.


Why Secure Randomness Matters

Randomness plays a critical role in many systems developers build.

Common use cases include:

  • Gaming mechanics and match outcomes
  • Digital rewards and raffles
  • Random selection in marketplaces
  • Secure token or identifier generation
  • Fairness mechanisms in distributed systems

The challenge is ensuring randomness cannot be predicted or manipulated.

If randomness is generated locally or in ways that can be influenced by system actors, outcomes may no longer be fair.

The Kurier Random Hash Oracle provides a structured way to request randomness and receive the result through an oracle fulfillment workflow.


Quickstart: Adding Randomness to an Application

Integrating the Kurier RNG service follows a simple workflow:

  1. Create and fund a subscription
  2. Deploy or configure a consumer system that can request randomness
  3. Authorize the consumer to use the subscription
  4. Call requestRandomHash()
  5. Receive the random hash through a callback

Once configured, applications can safely request randomness whenever it is needed.


Architecture: Random Hash Oracle Request Flow

The Kurier RNG service follows a request → fulfillment pattern.

What happens step-by-step

  1. An application or contract requests randomness
  2. The coordinator registers the request
  3. Oracle infrastructure detects the request event
  4. A random hash is generated
  5. The oracle fulfills the request
  6. The requesting system receives the random value

This architecture allows randomness to be delivered safely while keeping systems deterministic and predictable.


Step 1: Create and Fund a Subscription

Randomness requests are paid for through a subscription.

Each request draws from the subscription balance using the network's native token.

First, create a subscription through the oracle coordinator. This returns a subscriptionId, which will be used throughout the rest of the setup.

Next, fund the subscription.

Once funded, the subscription can be used to pay for randomness requests.


Step 2: Implement the Consumer Request

Your application or smart contract must expose a function that forwards randomness requests to the oracle coordinator.

When the request function is called:

  1. A randomness request is registered
  2. The oracle generates a random hash
  3. The result is delivered through a callback

This workflow allows applications to safely consume randomness when needed.


Step 3: Deploy the Consumer System

After implementing the request logic, deploy the consumer application or smart contract.

Typical configuration includes:

  • The subscription ID
  • The oracle coordinator address

These values allow the consumer to communicate with the Kurier oracle service.


Step 4: Authorize the Consumer

Once deployed, the consumer must be authorized to use the subscription.

Randomness requests will fail if the consumer has not been authorized.


Step 5: Request a Random Hash

Once the system is configured, randomness can be requested.

The oracle workflow then executes:

  1. The request is submitted to the coordinator
  2. The oracle generates randomness
  3. The coordinator fulfills the request
  4. The random hash is delivered to the consumer

Applications can then use the random value within their application logic.


Request Costs

Randomness requests are paid from the subscription balance.

Each request typically includes:

  • An oracle service fee
  • Gas costs associated with the callback execution

The coordinator reserves funds based on the callback gas limit and settles the final cost once the request is fulfilled.

Developers can query the coordinator contract to estimate request costs before submitting transactions.


Integration Flow

Most teams integrate the Kurier RNG service using the following steps:

  1. Choose a network and oracle coordinator deployment
  2. Create a subscription
  3. Fund the subscription
  4. Deploy or configure a consumer system
  5. Authorize the consumer with the subscription
  6. Submit randomness requests
  7. Receive the random hash via callback

Once configured, applications can safely request randomness whenever needed.


Example Use Cases

Gaming Platforms

Randomness determines outcomes such as loot drops, matchmaking results, and reward distribution. Oracle-based randomness ensures these outcomes cannot be manipulated.

Digital Marketplaces

Platforms can use randomness to distribute rewards or select featured items. This prevents bias in selection systems.

Lottery and Raffle Systems

Random winner selection requires strong guarantees that results cannot be manipulated. Oracle-delivered randomness provides this assurance.


Troubleshooting Common Issues

Not Authorized Consumer

The consumer system has not been added to the subscription. Make sure to authorize the consumer with the coordinator.

Wallet Cannot Estimate Gas

This usually indicates a transaction revert. Check that:

  • The subscription is funded
  • The consumer is authorized
  • The callback gas limit is within allowed bounds

Callback Failure

This usually means the callback gas limit is too low. Increase the callbackGasLimit parameter when requesting randomness.


Reliable Randomness for Modern Applications

Randomness is a critical primitive for many modern systems. But generating randomness that is secure, unpredictable, and verifiable can be challenging.

The Kurier RNG service provides developers with a simple way to request random hashes through a reliable oracle workflow.

Applications can integrate randomness into their systems while maintaining predictable infrastructure and fair outcomes.