https://github.com/igi-111/vrf
A simple VRF library for Sway
https://github.com/igi-111/vrf
Last synced: about 1 month ago
JSON representation
A simple VRF library for Sway
- Host: GitHub
- URL: https://github.com/igi-111/vrf
- Owner: IGI-111
- Created: 2025-08-10T22:13:15.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2025-08-10T23:24:30.000Z (2 months ago)
- Last Synced: 2025-08-11T01:10:56.874Z (2 months ago)
- Language: Sway
- Size: 2.93 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `vrf` a Sway Library for verifiable random number generation
`vrf` is a simple library to access VRF implementations on Fuel, currently supporting:
- [SimpleVRF](https://github.com/darthbenro008/simplevrf)
To get started simply add it to your contract:
```
forc add vrf@0.1.2
```and call it like so:
```sway
use vrf::{Vrf, VrfResult};// ...
let seed = 0xd167b328cc944e4ff79f18e8f0431165; // this is a random seed you should generate yourself (most likely off chain)
let vrf = Vrf::testnet(); // or Vrf::mainnet() if you want to run on mainnet
vrf.request_random(seed);// ... wait a while and store the seed somewhere ...
match vrf.get_random(seed) {
VrfResult::Pending => {} // we are still waiting for the number to be generated
VrfResult::Failure => {} // something went wrong
VrfResult::Success(num) => log(num), // we did generate a random number, and it is num
}```