L2 Services

Registering and Using Oracle Network Services on L2 Chains

Registry Contract

This contract allows you to manage new chain and Orakl Network services.

L2 Chain Management

Please contact Orakl Network after you propose a new chain. We will support you to set things up.

  1. Propose New Chain and Pay proposeFee

function proposeNewChain(
    uint256 _chainID,
    string memory _jsonRpc,
    address _endpoint
) external payable {
    if (msg.value < proposeFee) {
        revert NotEnoughFee();
    }
    if (chainRegistry[_chainID].owner != address(0)) {
        revert ChainExisted();
    }
    pendingProposal[_chainID].jsonRpc = _jsonRpc;
    pendingProposal[_chainID].endpoint = _endpoint;
    pendingProposal[_chainID].owner = msg.sender;
    emit ChainProposed(msg.sender, _chainID);
}
  1. Edit Chain Info

Account and Payment Functions

Before you can make a request from L2 chain, you need to create and deposit to your account.

  1. Create Account

  1. Deposit Funds Into the Account

  1. Add Consumer Into Account

  1. Remove Consumer From Account

The consumer address to add or remove to this account is on L2 chain, not mainnet.

Endpoint Contracts

L2Endpoint

You need to deploy this contract on your chain; it acts as a coordinator for VRF and Request-Response.

  1. Request Random Words From L2

  1. Request Data From L2

How to Integrate VRF and Request-Response on L2

VRF

Refer to L2 VRF mock consumer contract.

  1. Inherit from the VRFConsumerBase Contract

  1. Specify l2Endpoint in the Constructor

  1. Implement the requestRandomWords Function

  1. Implement the fulfillRandomWords Function

Request-Response

Refer to L2 Request-Response mock consumer contract.

  1. Inherit from the Base Contract for Request Data Types

  1. Specify l2Endpoint in the Constructor

  1. Implement requestData* Function

  1. Implement the fulfillDataRequest Function

Last updated