Skip to content

We make on chain verifiable randomness affordable and easy to use. Turning async to sync since 2024. randomnumberretailer.eth

Notifications You must be signed in to change notification settings

RNRetailer/RandomNumberRetailer

Repository files navigation

Random Number Retailer LLC

We make on chain verifiable randomness affordable and easy to use.

Turning async to sync since 2024

randomnumberretailer.eth

Sepolia example client: https://sepolia.etherscan.io/address/0x601f6b7dde87d8e3e7325b2dc8194b2cbab7bf79#code

Test webite: https://rnretailer.github.io/RandomNumberRetailer/rnr-test-website-sepolia/

Sepolia smart contract: https://sepolia.etherscan.io/address/0xd058eA7e3DfE100775Ce954F15bB88257CC10191

Twitter: https://twitter.com/RNRetailer

Discord: https://discord.gg/ugrjPCyfWd

reddit: https://reddit.com/r/randomnumberretailer

--

For this method (the casual method):

function requestRandomNumbersSynchronous(

uint256 amountOfRandomNumbersToRequest,

uint256[] memory randomSeedArray

)

It is useful in a few scenarios:

  1. Methods that are only callable by the contract owner / trusted parties who just need a truly random outcome for their own purposes.

  2. Public methods where there is no financial outcome on the line (picking what avatar you get, what team you're on, etc.)

--

For anything more serious this method should be used (the advanced method):

function requestRandomNumbersSynchronousUsingVRFv2Seed(

uint256 amountOfRandomNumbersToRequest,

Proof memory proof,

RequestCommitment memory rc

)

This method requires a random proof generated by Chainlink VRF v2 or equivalent.

It takes about one second on my computer to generate a single verified random proof.

It is not tenable for a MEV bot to generate the perfect random number in a block's time if they need to create VRF v2 proofs.

Of course, a fully asynchronous method is more secure and should continue to be used in high stakes environments.

We may release our own fully asynchronous alternative which would basically be exactly like Chainlink VRF v2 but you would pay in ETH instead of LINK.

But for anything remotely casual you can save a lot of time and money using our advanced method, especially if it is combined with something like Flashbots RPC to avoid MEV.

Plus you get all of the convenience of synchronicity.

--

Random Number Retailer: Random Numbers Just Got a Whole Lot Cheaper... And Easier Too!

This program has two major aims:

  1. Reduce the price of verifiably random numbers on chain when requested in small batches.

    As of 2/29/24, Chainlink VRF v2 charges a similar amount for anywhere between one and five hundred random numbers.
    This means that getting a single random number is about as expensive as getting five hundred random numbers!

    This smart contract charges a set price per random number, making requests for small amounts of random numbers much cheaper.
    The price we charge per random number is determined by priceOfARandomNumberInWei.

    We will try to keep the price much lower for small batches of random numbers than if the caller purchased them from Chainlink VRF v2.
    Additionally, we accept ETH for the random numbers instead of LINK, which makes our contract way easier to use than Chainlink VRF v2 and saves the caller a ton of gas.
    For many applications, we expect the cost savings to be significant.

  2. Convert Chainlink VRF v2 from async to sync, drastically improving its ease of use.

    By design, Chainlink VRF v2 is asynchronous: first, you make a transaction to the VRF v2 coordinator to request the random numbers.

    Then, some unknowable time in the future, Chainlink *might* call the callback method on your smart contract with the random numbers you've requested.

    This asynchronous design makes using verifiable randomness on the blockchain extremely awkward and cumbersome.

    This smart contract allows the caller to request random numbers in a completely synchronous fashion.
    The random numbers are returned instantly from this contract when requested, drastically improving on Chainlink's ease of use and flexibility.

    With this smart contract, there is no need for a callback method, and no need to wait for a second transaction.

    You will receive your random numbers immediately with no hassle.
    Instructions for using this contract:

  3. Begin by checking randomNumbersAvailable to see how many random numbers are available for purchase.
    Then, create a uint256 specifying how many random numbers you wish to buy.
    Let's call that amountOfRandomNumbersToRequest.
    Remember that other callers can buy random numbers during the same block, so it's possible the amount of random numbers you can buy is lower than randomNumbersAvailable.
    However, we constantly supply additional random numbers to this contract when randomNumbersAvailable goes below minimumHealthyLengthOfRandomNumbersArray.
    As long as this contract is active, it should usually have a healthy supply of random numbers available for purchase.

  4. Next, multiply priceOfARandomNumberInWei by amountOfRandomNumbersToRequest.
    We'll call that totalPrice.
    This is the amount of ETH in wei that you must explicitly pay when requesting random numbers from this smart contract.

  5. Generate an array of uint256 random seeds. Let's call it randomSeedArray.
    To maximize safety and randomness, you should ideally generate your random seeds off of the blockchain, in a traditional programming language.
    If the user is calling your smart contract in a web browser, you can use JavaScript to generate different random seeds for each call.
    If you are calling the smart contract from a server, you should generate the random seeds in your programming language of choice.
    It is possible to generate pseudorandom seeds on the blockchain, but it is not ideal.
    If your random seeds are too easily guessable, a validator or MEV bot could attack your smart contract.

  6. Call requestRandomNumbersSynchronous(amountOfRandomNumbersToRequest, randomSeedArray) and set the value of the transaction to totalPrice.
    If the call succeeds, an array of verifiably random uint256 numbers will be returned.
    The length of the returned array will be equal to amountOfRandomNumbersToRequest.
    Now, you can use verifiably random numbers in your smart contract in an easy, affordable, and synchronous manner!

    Advanced users can call requestRandomNumbersSynchronousUsingVRFv2Seed instead to swap their Chainlink VRFv2 proof for our verifiably random numbers.

Future plans:

  1. Deployment on other blockchains
    We are planning on deploying a version of this contract on all blockchains that support Chainlink VRF v2.
    Currently, that includes Ethereum, Arbitrum, Polygon (Matic), Avalanche, BNB Chain, and Fantom.
    We will also deploy contracts to each blockchain's respective testnets.
    We will try to keep the owner / deployer and server addresses consistent across blockchains so you can verify the legitimacy of the smart contracts.
    We may also deploy to additional blockchains as needed.

  2. Token airdrop
    At some point, we plan on releasing an ERC20 token that rewards the use of our smart contracts.
    The more random numbers you've purchased from one of our smart contracts on a given blockchain, the larger the airdrop you'll receive on that blockchain.
    Testnets will not receive the airdrop.
    Tokens will be airdropped on all nontestnet blockchains that contain one of our smart contracts.
    The tokens should be able to flow seamlessly between all supported blockchains.
    These tokens are not securities and you should not expect us to try to increase their price.

Legal:
Random Number Retailer LLC Copyright 2024

Random Number Retailer LLC is a Limited Liability Company registered in the state of New Mexico, United States of America.

Anyone who is not sanctioned by the United States of America is allowed to read the public variables of this smart contract.

Anyone who is not sanctioned by the United States of America can call the following methods by submitting a transaction to the blockchain on which this smart contract resides:
randomNumbersAvailable
requestRandomNumbersSynchronous
requestRandomNumbersSynchronousUsingVRFv2Seed

Anyone processing transactions for the blockchain on which this smart contract resides can process any transaction associated with this smart contract in the standard manner. No special behavior is required.

No person or entity other than Random Number Retailer LLC is allowed to call any method with the modifiers onlyServer or onlyOwner by submitting a transaction to the blockchain on which this smart contract resides without the explicit consent of Random Number Retailer LLC.

The code for the "RandomNumberRetailer" contract is available to view publicly, but no party other than Random Number Retailer LLC can reuse any of this proprietary code in a separate smart contract or program of any sort without the explicit consent of Random Number Retailer LLC.

Any person or entity who reuses any part of this code in a separate smart contract or program without the explicit consent of Random Number Retailer LLC may be subject to legal action.

Contact:
As of 2/29/24, Random Number Retailer LLC uses a gmail account for most correspondence.
Please email [email protected] with any proposals, feedback, etc.
Keep up with our announcements on Twitter / X: https://twitter.com/RNRetailer or https://x.com/RNRetailer

About

We make on chain verifiable randomness affordable and easy to use. Turning async to sync since 2024. randomnumberretailer.eth

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published