Generating on-chain random

On-chain random numbers refer to the RNG on a blockchain network, and these are commonly used in various apps and smart contracts. The need for on-chain random numbers arises from the desire to introduce unpredictability and fairness in business processes.

To get this number using the sdk, follow this code,

const generateRandom = async () => {
    const res = await client.client.random.generateRandom();
    console.log("res", res);
    console.log("random number", res.result.result);
};

Last updated