On-chain verifiable randomness
pip install pragma-sdk
python3 -m pragma-sdk.cli random verify-random <TRANSACTION_HASH>
where TRANSACTION_HASH
is the hash of the Starknet testnet transaction in which the randomness was submitted to your smart contract.Fee Token | Testnet | Mainnet |
---|---|---|
ETH | ✅ | ✅ |
STRK | ❌ | ❌ |
callback_fee_limit
parameter that will be paid in the transaction’s fee token. When randomness is submitted to the consumer contract, the fee excess is refunded.Total Number of Requests | Price (USD) |
---|---|
< 10 | 1$ |
< 30 | 0.5$ |
< 100 | 0.25$ |
> 100 | 0.1$ |
request_random
receive_random_words
on your contract.
seed
: random seed that feeds into the verifiable random algorithm, must be different every time.callback_address
: address to call receive_random_words
on with the randomnesscallback_fee_limit
: overall fee limit on the callback functionpublish_delay
: minimum number of blocks to wait from the request to fulfillmentnum_words
: number of random words to receive in one call. Each word is a felt252.calldata
: calldata we want to pass down to the callback functionrequest_id
: ID of the request, which can be used to check the status, cancel the request and check that the callback function was correctly called.receive_random_words
callback_address
initially passed in the randomness request.
requestor_address
: address that submitted the randomness requestrequest_id
: id of the randomness request (auto-incrementing for each requestor_address
)random_words
: an span of random wordscalldata
: calldata passed in the random requestcancel_random_request
request_id
: ID of the request to be canceledseed
: seed used to request the randomnessrequestor_address
: address of the contract that originally requested the randomness. Currently must be the same as the contract calling the cancel functionminimum_block_number
: the block number in which the randomness could first have been published, equal to publish_delay
+ block_number
of the requestcallback_address
: argument provided in the randomness requestcallback_fee_limit
: argument provided in the randomness requestnum_words
: argument provided in the randomness requestget_request_status
requestor_address
: address of the requesting contractrequest_id
: ID of the request to be canceledstatus_
: status of the request, see here.
There are four defined status:
0=UNINITIALIZED, 1=RECEIVED, 2=FULFILLED, 3=CANCELLED, 4=OUT_OF_GAS