npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@niuxiaojie88/contracts-vrf

v1.1.0

Published

vrf contracts

Downloads

1

Readme

VRFContract

PlatON built-in contract (contract address: 0x30000000000000000000000000000000000001) generates VRF random numbers for users. The Solidity contracts in this repository refer to the usage of Chainlink VRF, encapsulate the invocation of built-in contracts, and at the same time make the entire invocation process of the contract consistent with Chainlink, so that users can quickly migrate Chainlink VRF-based services to PlatON VRF.

Contract Overview

VRF.sol

The VRF contract directly calls the PlatON built-in contract through delegatecall and returns a list of random numbers. If the user's current business does not involve the Chainlink VRF process, the contract can be deployed directly.

VRFCoordinatorV2.sol

The Coordinator contract refers to Chainlink VRF related contracts, and provides subscription management and Consumer contract registration functions, which is convenient for Consumer contracts to access and use VRF functions. Different from Chainlink VRF, the Coordinator contract provides users with two ways to obtain random numbers, i.e. the synchronous and the asynchronous, and cancels the settlement of Link Token related fees.

VRFv2Consumer.sol

The contract provides a Consumer contract template, to which users can refer to call the Coordinator contract to obtain random numbers for business processing.

Contract Usage

  1. Deploy the VRCoordinatorV2 contract and the contract address vrfCoordinatorAddress is returned.

  2. Create a Subscription in VRCoordinatorV2 and the subscription SubId is returned.

  3. Deploy the VRFv2Consumer contract, pass in vrfCoordinatorAddress and SubId as the constructor parameters, and the contract address consumerAddress is returned.

  4. Register the Consumer contract with VRCoordinatorV2, pass in SubId and consumerAddress as parameters.

  5. Call the syncRequestRandomWords method of the Consumer contract to obtain a list of random numbers synchronously.

  6. Call the requestRandomWords method of the Consumer contract to asynchronously request VRF random numbers, and the generated random numbers are returned by the callback function fulfillRandomWords.