1.2.0 • Published 9 months ago

@arrng/contracts v1.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

arrng contract package

A library to implement arrng for verifiable rng in blockchain apps. aarng implements an oracle to serve signed randomness from random.org to a number of chains, including:

  • mainnet
  • arbitrum one
  • optimism
  • polygon
  • eth goerli
  • eth sepolia
  • arbitrum goerli
  • optimism goerli
  • polygon mumbai

For more details please see https://www.arrng.io/.

Overview

Installation

$ npm install @arrng/contracts

An alternative to npm is to use the GitHub repository (arrng/arrng-contracts) to retrieve the contracts.

Usage

Once installed, use arrng by importing the consumer contract. Either pass in the arrng controller address on your constructor or use the hardcoded address below.

aarng is at 0x000000000000f968845afB0B8Cf134Ec196D38D4 on all supported chains.

pragma solidity ^0.8.0;

import "@arrng/contracts/ArrngConsumer.sol";

contract MyArrngConsumer is ArrngConsumer {
    constructor() ArrngConsumer(0x000000000000f968845afB0B8Cf134Ec196D38D4) {
    }
}

If you're new to smart contract development, we recommend heading to openzeppelin for a great guide to Developing Smart Contracts, to learn about creating a new project and compiling your contracts.

To request randomness from arrng (for example one number):

iD = arrngController.requestRandomWords {value: msg.value} (1);

The iD returned is a uint256 which uniquely identifies your request on that chain. You will need to send enough native token (e.g. ETH) for the response with the random number. This is served by api.arrng.io. See https://www.arrng.io/ for details.

The arrng oracle will wait for six confirmations before responding. To receive the response and use it in your contract you will need to include the fullfillRandomWords internal function.

See an example contract at https://github.com/arrng/arrng-contracts/blob/main/contracts/mock/MockConsumer.sol.

1.2.0

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.1.2

9 months ago

1.0.1

12 months ago

1.0.0

12 months ago