verifiable random function

Fuel VRF Secure and Provable Randomness

ORAO VRF generates secure, unbiased, and provable randomness for Fuel Network dApps using a multinode architecture and byzantine quorum. This technology ensures that the randomness is transparent and cannot be tampered with, making it ideal for various use cases that require trust and fairness. Fuel Network's high-performance blockchain provides fast and reliable execution of smart contracts, and with ORAO VRF, developers can add a layer of trust and security to their applications.

Start building with ORAO VRF

Fuel VRF developer's guide

Javascript SDK
Fuel VRF JS library has been recently updated to support latest Fuel SDK. We've built a sample app with minimal frontend to demo VRF offchain request and fulfillment in JS.
copied to clipboard
//import the library
import { Vrf } from "../lib/fuel/index.js";

//initialize VRF
const vrf = new Vrf(wallet!);

//initialize seed
const seed = new Uint8Array(32);

//request and await
await vrf.request(`0x${Buffer.from(seed).toString("hex")}`)
                        
Sway SDK
The SDK is compatible with Fuel Testnet and Sway v0.60.0. Inside the SDK you'll find the ORAO VRF library and two apps: The Rust SDK is documented in detail on docs.rs.
copied to clipboard
use vrf_abi::{randomness::{Fulfilled, Randomness, RandomnessState}, Vrf};

const VRF_ID = 0x749a7eefd3494f549a248cdcaaa174c1a19f0c1d7898fa7723b6b2f8ecc4828d;

/// Helper that calls "spin_and_pull_the_trigger" on a russian roulette instance.
pub async fn spin_and_pull_the_trigger(&self) -> anyhow::Result<()> {
	// using random "force" - generates a boolean
	let force = rand::random();

	// we need to get the correct fee
	let fee = self
		.methods()
		.round_cost()
		.with_contract_ids(&[orao_fuel_vrf::CONTRACT_ID.into()])
		.simulate()
		.await?
		.value;

	println!("VRF fee is: {:?}", fee);

	self.methods()
		.spin_and_pull_the_trigger(Bits256(force))
		.with_tx_policies(TxPolicies::default())
		.call_params(CallParameters::default().with_amount(fee))?
		.with_contract_ids(&[orao_fuel_vrf::CONTRACT_ID.into()])
		.call()
		.await?;

	Ok(())
}
Javascript SDK
Sway SDK

Request and fulfilment flow

ORAO VRF was designed to be secure, unbiased, affordable and fast randomness generator.

The request:
Client requests randomness from the on-chain contract. Multiple nodes respond to the request by each generating randomness and signing it on-chain.
The fulfillment:
The randomness request is fulfilled when nodes reach a byzantine quorum. Client checks if its request for a given seed is fulfilled and verifies the signatures.

1. Client submits a VRF request

2. VRF nodes detect changes on all randomness accounts

3. VRF nodes generate randomness and send it on-chain

4. ORAO VRF Program checks signatures and XORs the randomness given by authoritative nodes

5. When a byzantine quorum is achieved the randomness request is fullfilled and stored to the on-chain account for usage