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

super-random-evm

v1.0.0

Published

EVM package with varying levels of randomness.

Downloads

12

Readme

superRandom

EVM library for easily accessing varying levels of randomness.

Only supports Rinkeby for now.

Goals

Create an easy way to get random numbers on chain without having to rely on third party oracles. Provide varying degrees of randomness to meet a user's needs.

Why an EVM package?

Why not a library like safemath? In order to do Ultra and better levels of randomnes onchain some kind of state must be stored. It is impossible to have that high level of randomness from pure functions. We must use a future hash that can't be predicted in our request for random numbers, so some kind of timer system must be used & stored.

Installation

Requires a recent version of nodejs and npm. This package is published with Zeppelin OS

npm install zos
npx zos link super-random-evm

Decent

DecentRandom.sol is a standalone pseudo random generating tool. It's randomness is decent, but could be slightly influenced by the miner of the block when random numbers are generated. The Decent random getter should not be used if any significant amount of value is on the line, but it will be good for many simple uses.

Use

Using the Decent random functions is easy. There are 2 main ways to intereact with the Rinkeby deployment, which is deployed here:

  1. Get a random uint256: call the getRandom() function on DecentRanom.
  2. Get a random uint256 between 0 and some max number: call the getRandomLimit(maxnumber) function.

You can test these on Rinkeby manually here: https://oneclickdapp.com/eric-nurse

Ultra

Use of Ultra is more complicated but results in much more random numbers. The Ultra contract is an ownerless clone of the cryptokitties breeding algorithm, but without kitties. It requires the user asking for a random number to choose a future block. Later, during or after that block is mined, the unpredictable hash of the chosen block is used in conjunction with other previously generated random numbers to generate a new random uint256 via another hash.

Use

There is a new Rando object, similar to a crypto-collectible like cryptokitties, but without ownership. They are used to generate a new random number. Each has a unique ID, a random uint, a check to see if it is pending being used, and some other data.

First, to request a new random number from Ultra call the putRandom(...) function. The function takes three parameters and sets up a random number generation at a later time instead of immediately returning one. The parameters are:

  1. A future block number, at least 5 from now. You can get this this by doing something like uint futureblock = block.number + 5.
  2. An ID for any Rando object with is not pending. The corresponding Rando object for that that ID will be set to pending.
  3. The ID for a second Rando object, the attributes of which will be used in the hash to create a new random number but will not be set to pending.

Second, we all wait until the future block selected has passed.

Thirdly, anyone can call the pullRandom() function to generate a new Rando object with a new random number affiliated with it. The function takes the ID of a Rando object that is both pending, and which has been waiting at least the specified number of blocks.

Because we need to call the pullRandom() function later, we need to give an incentive to "random hunters" to spend their time and gas on calling the function as soon as possible. It won't work if it's called after 256 blocks of being ready. So putRandom() requires a small 0.005 ETH payment, which goes to whoever calls pullRandom() successfully.