DOCUMENTS

Documents of the BORA project.

RandomNumber APIs

The RandomNumber API is to generate/get/verify random numbers.

1 Request to generate a random number

POST /sc/randomnumber/v2/admin/{contractId}/requestrandom HTTP/1.1
HOST: testnet-chain-api.boraecosystem.com

Parameters

ParameterRequiredValuesDescriptionParameter TypeData Type
Authorization*Bearer {Client's AccessToken}headerstring
contractId*RandomNumber contract IDurlint
account*User Wallet address to generate a random numberformDatastring, length(42)
blockOffset*Generates a random number after blockOffset blocksformDataint, minimum(0)
maxNumber*Max Number of random number to generateformDataint

Response

{
"status": 200,
"data: {
"tx_hash": "0x4e6645aa749faca3cf16140d45f8180d1fd8c2fada732faf5beeaa35519b76c5",
"seq": 12 }
}

2 Get the requested random number

GET /sc/randomnumber/v2/randomnumber/{contractId}/getrandom HTTP/1.1
HOST: testnet-chain-api.boraecosystem.com

Parameters

ParameterRequiredValuesDescriptionParameter TypeData Type
Authorization*Bearer {Client's AccessToken}headerstring
contractId*RandomNumber contract IDurlint
account*User Wallet address used for the requested random numberquerystring, length(42)
seq*Received seq when requested random numberqueryint

Response

{
"status": 200,
"data: {
"id": 11,
"contract_id": 4,
"account": "0x9961064b96c71ce47f3a14a1c7456de7fb5ec644",
"request_block_no": 10684,
"block_offset": 1,
"expected_block_no": 10685,
"block_hash": "0x474bd720ebafa9c17f81b2c9a4f9e2452ed4ebc1ec81c0f89dc49f226094b37b",
"seed": "0xa5f369b0eb0f4327768b50fcfccb66569c85d84e87882847364b55d8c25181bf",
"sequence": 12,
"min_number": 1,
"max_number": 100,
"random_number": 15,
"app_no": 100004,
"tx_hash": "0x4e6645aa749faca3cf16140d45f8180d1fd8c2fada732faf5beeaa35519b76c5",
"verified": 1,
"created_at": "2019-02-13 19:25:55",
"updated_at": "2019-02-13 19:25:58"
}
}

3 Verify the random number

GET /sc/randomnumber/v2/randomnumber/{contractId}/verifyrandom HTTP/1.1
HOST: testnet-chain-api.boraecosystem.com

Parameters

ParameterRequiredValuesDescriptionParameter TypeData Type
Authorization*Bearer {Client's AccessToken}headerstring
contractId*RandomNumber contract IDurlint
account*User Wallet address of random number requestquerystring, length(42)
reqBlockNum*request_block_no of random number resultqueryint
blockOffset*blockOffset of random number requestqueryint
seq*Received seq when requested random numberqueryint
maxNumber*maxNumber of random number requestqueryint

Response

{
"status": 200,
"data: {
"status": 1,
"blockHash": "0x474bd720ebafa9c17f81b2c9a4f9e2452ed4ebc1ec81c0f89dc49f226094b37b",
"seed": "0xa5f369b0eb0f4327768b50fcfccb66569c85d84e87882847364b55d8c25181bf",
"random": 15,
"lastSeq": 13,
"expBlockNum": 10685,
"currBlockNum": 10701
}
}

Error Code

HTTP CodeStatusDescriptionExample
200400Validation Error: Invalid parameters.
{
"status": 400,
"error": [
{
"message": "integer validation failed on index",
"field": "index",
"validation": "integer"
}
]
}
200401Unauthorized: You aren’t authenticated.
{
"status": 401,
"error": [
{
"message": "E_FORBIDDEN: Access Token is not right",
}
]
}
200404Not Found: Failed to find URL.
{
"status": 404,
"error": [
{
"message": "E_ROUTE_NOT_FOUND: Route not found GET /erc721",
}
]
}
200422Unprocessable Entity: The request was unable to be followed.
{
"status": 422,
"error": [
{
"message": "E_CONTRACT_NOT_FOUND: contractId not found",
}
]
}
200500Internal Server Error: Internal Server Error.
{
"status": 500,
"error": [
{
"message": "E_DATABASE_ERROR: Internal database error",
}
]
}
4XX, 5XXOther Error
HTTP Code: 503
Body: Reponse: 503, Under Maintenance