Verifiable Randomness on FairyRing
FairyRing can provide a Verifiable Random String via a functionality in its KEYSHARE module.Approach 1: IBC Query
Use IBC to make a query on the FairyRing chain. This is the simplest way for other Cosmos chains to fetch Randomness from fairyRing, since IBC is a core part of the Cosmos-SDK. However, it can work with other EVM chains as well if they have an IBC implementation.Requirements
- A working IBC channel between the Native chain and FairyRing.
- IBC Relayer for Native Chain-FairyRing communication
- Implementation of an IBC query logic in the native chain
Code Sketch
Advantages
- Fully onchain and decentralized process of transmission
- Default Merkle proof verification of date across chains
Disadvantages
- Requires Native Chain to have IBC capabilities
- There may be some delay in the Request-Response cycle due to strict verifications enforced by IBC
Approach 2: Use FairyRing Gateway Smart Contract
For EVM chains, the simplest way to fetch Randomness from FairyRing is to deploy the standard FairyRing Gateway Contract on the native chain. Then, Fairyport, a specialized cross-chain relayer for FairyRing, can be used to relay the VRF from FairyRing to this contract.NOTE: Fairyport is a relayer, custom-made for relaying information between Fairyring and other chains. (Currently supports EVM and Cosmos chains), However, the randomness can be locally verified on the Native chain through cryptography; the relayer doesn’t need to be blindly trusted.
Setup
- Deploy FairyringGateway.sol on Native Chain.
- Configure Fairyport to relay VRF data from Fairyring to this contract.
Advantages
- Works out of the box with minimal changes.
Disadvantages
- Fixed interface; flexibility might be limited.
Approach 3: Custom Smart Contract + Fairyport Integration
For EVM chains, a more flexible, but more involved, way of fetching randomness from Fairyring is to create a custom gateway contract tailored for the said Native chain. This would allow for custom processing of the randomness and application-specific logic to be applied on when to request Randomness and how to process it. Once the contract is deployed on the Native chain, the Fairyport relayer can be used to relay the Randomness to this custom contract, rather than the default gateway contract.Setup
- Write and deploy a new Solidity contract on the Native chain.
- Modify Fairyport to encode VRF data and send it to this new contract.
Advantages
- Maximum flexibility.
- Allows custom access control and business logic.
Disadvantages
- Requires development effort on both the smart contract and Fairyport
- Slightly more complex setup