Random module: Endpoint reference

This page summarizes all API endpoints specific to the Random module.

All the aforementioned endpoints can be invoked using the random prefix.

Endpoints can be invoked as explained in the Connecting via endpoints guide.

random_isSeedRevealValid

Checks whether the seedReveal of a particular validator is valid. The response is a boolean value.

  • Specification

  • Node CLI

  • cURL

Name Type Description Sample

generatorAddress

string

The Klayr32 address of a validator.

klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99

seedReveal

string

The value revealed by the generator of the block for the commit and reveal process.

c0f96ff4416b6c9ff0f641527dec0a27

klayr-core endpoint:invoke random_isSeedRevealValid '{"generatorAddress":"klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99", "seedReveal":"c0f96ff4416b6c9ff0f641527dec0a27"}' --pretty
curl --location 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "random_isSeedRevealValid",
    "params": {
        "generatorAddress": "klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99",
       "seedReveal":"c0f96ff4416b6c9ff0f641527dec0a27"
    }
}'
Response
Example output
{
  "valid": true
}

random_setHashOnion

Sets the hash onion of a validator.

  • Specification

  • Node CLI

  • cURL

Name Type Description Sample

address

string

The Klayr32 address of a validator.

klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99

seed

string

Seed hash value for the hash onions.

c0f96ff4416b6c9ff0f641527dec0a27

count

string

The total number of hash onions.

1000000

distance

string

Distance between each hash.

1000

klayr-core endpoint:invoke random_setHashOnion '{"address":"klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99", "seed": "e025160dfc93688a01c96ab9f3e0a29e", "count": 1000000, "distance": 1000}' --pretty
curl --location 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "random_setHashOnion",
    "params": {
        "address": "klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99",
        "seed": "e025160dfc93688a01c96ab9f3e0a29e",
        "count": 1000000,
        "distance": 1000
    }
}'
Response
Example output
{}

random_getHashOnionSeeds

Retrieves the hash onion seeds of a validator.

  • Specification

  • Node CLI

  • cURL

Name Type Description Sample

address

string

The Klayr32 address of a validator.

klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99

klayr-core endpoint:invoke random_getHashOnionSeeds '{"address":"klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99"}' --pretty
curl --location 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "random_getHashOnionSeeds",
    "params": {
        "address": "klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99"
    }
}'
Response
Example output
{
  "seeds": [
    {
      "address": "klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99",
      "seed": "e025160dfc93688a01c96ab9f3e0a29e",
      "count": 1000000,
      "distance": 1000
    }
  ]
}

random_hasHashOnion

Checks if a validator has a hash onion.

  • Specification

  • Node CLI

  • cURL

Name Type Description Sample

address

string

The Klayr32 address of a validator.

klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99

klayr-core endpoint:invoke random_hasHashOnion '{"address":"klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99"}' --pretty
curl --location 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "random_hasHashOnion",
    "params": {
        "address": "klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99"
    }
}'
Response
Example output
{
  "hasSeed": true,
  "remaining": 1000000
}

random_getHashOnionUsage

Returns the hash onion usage for a validator.

  • Specification

  • Node CLI

  • cURL

Name Type Description Sample

address

string

The Klayr32 address of a validator.

klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99

klayr-core endpoint:invoke random_getHashOnionUsage '{"address":"klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99"}' --pretty
curl --location 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "random_getHashOnionUsage",
    "params": {
        "address": "klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99"
    }
}'
Response
Example output
{
  "usedHashOnions": [
    {
      "count": 0,
      "height": 0
    }
  ],
  "seed": "e025160dfc93688a01c96ab9f3e0a29e"
}

random_setHashOnionUsage

Sets the hash onion usage for a validator.

  • Specification

  • Node CLI

  • cURL

Name Type Description Sample

address

string

The Klayr32 address of a validator.

klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99

usedHashOnions

Object[]

Defines the number of times hash onions are used and also the block height of the usage.

"usedHashOnions": [
    {
        "count": 10,
        "height": 100
    }
]
klayr-core endpoint:invoke random_setHashOnionUsage '{"address":"klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99", "usedHashOnions": [{"count": 10, "height":100 }]}' --pretty
curl --location 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "random_setHashOnionUsage",
    "params": {
        "address": "klydwsyfmcko6mcd357446yatromr9vzgu7eb8y99",
        "usedHashOnions": [
            {
                "count": 10,
                "height": 100
            }
        ]
    }
}'
Response
Example output
{}