Comment on page
RNGServiceChainlinkV2
This contract implements a service that allows it to work with the Chainlink V2 to request randomness.
Allows the
pendingOwner
address to claim the owner role. This function is only callable by the pendingOwner
.Allows to initialize the contract during the deployment.
Parameters:
Name | Type | Description |
---|---|---|
_owner | address | An owner of the contract. |
_vrfCoordinator | address | An address of the VRF Coordinator. |
_subscriptionId | uint64 | Chainlink VRF subscription ID. |
_keyHash | bytes32 | Hash of the public key used to verify the VRF proof. |
Handles the VRF response. This function is only callable by the VRF Coordinator.
Parameters:
Name | Type | Description |
---|---|---|
_requestId | uint256 | The ID initially returned by requestRandomWords method. |
_randomWords | uint256[] | The VRF output expanded to the requested number of words. |
Leaves the contract without owner. It will not be possible to call the owner's functions anymore. Can only be called by the current owner. The method does not take any parameters. Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
Sends a request for a random numbers to the 3rd-party service. Some services will complete the request immediately, others may have a time-delay. Some services require payment in the form of a token, such as LINK for Chainlink VRF. The calling contract should
lock
all activity until the result is available via the requestId
. This function is only callable by the manager.Parameters:
Name | Type | Description |
---|---|---|
_numWords | uint32 | An amount of random numbers to request. |
Return:
Name | Type | Description |
---|---|---|
_requestId | uint32 | The ID of the request used to get the results of the RNG service. |
_lockBlock | uint32 | The block number at which the RNG service will start generating time-delayed randomness. |
Sets Chainlink VRF key hash. This function is only callable by the owner.
Parameters:
Name | Type | Description |
---|---|---|
_keyHash | bytes32 | Chainlink VRF key hash. |
Allows the owner to give the manager role to an address. The manager role has access to the functions with the modified onlyManagerOrOwner.
Parameters:
Name | Type | Description |
---|---|---|
_newManager | address | A new manager address. |
Sets Chainlink VRF subscription ID associated with this contract. This function is only callable by the owner.
Parameters:
Name | Type | Description |
---|---|---|
_subscriptionId | uint64 | Chainlink VRF subscription ID. |
Transfers ownership of the contract to a
_pendingOwner
. Can only be called by the current owner.Parameters:
Name | Type | Description |
---|---|---|
_newOwner | address | An account that will become the _pendingOwner . |
Gets Chainlink VRF key hash associated with this service contract. A key hash is an identifier that maps to a job and a private key on the VRF service and that represents a specified gas lane. If your request is urgent, specify a gas lane with a higher gas price limit.
Return:
Name | Type | Description |
---|---|---|
_keyHash | bytes32 | Chainlink VRF key hash. |
Gets the last request ID used by the RNG service.
Return:
Name | Type | Description |
---|---|---|
_lastRequestId | uint32 | The last request ID used in the last request. |
Gets an array of random numbers produced by the 3rd-party service.
Parameters:
Name | Type | Description |
---|---|---|
_internalRequestId | uint32 | The ID of the request used to get the results of the RNG service. |
Return:
Name | Type | Description |
---|---|---|
_randomNumbers | uint256[] | An array of random numbers. |
Gets the fee for making a request against an RNG service.
Return:
Name | Type | Description |
---|---|---|
_feeToken | address | The address of the token that is used to pay fees. |
_fee | uint256 | The fee required to be paid to make a request. |
Gets Chainlink VRF subscription ID associated with this contract.
Return:
Name | Type | Description |
---|---|---|
_subscriptionId | uint64 | Chainlink VRF subscription ID. |
Gets Chainlink VRF coordinator contract address associated with this contract.
Return:
Name | Type | Description |
---|---|---|
_vrfCoordinator | address | Chainlink VRF coordinator address. |
Checks if the request for randomness from the 3rd-party service has completed. For time-delayed requests, this function is used to check/confirm completion.
Parameters:
Name | Type | Description |
---|---|---|
_internalRequestId | uint32 | The ID of the request used to get the results of the RNG service. |
Return:
Name | Type | Description |
---|---|---|
_isRequestCompleted | bool | true if the request has completed and a random number is available, false otherwise. |
Gets a manager address that was granted exclusive access to specific functions with the modifier onlyManagerOrOwner.
Return:
Name | Type | Description |
---|---|---|
_manager | address | A manager address. |
Gets an owner address that was granted exclusive access to specific functions with the modifier
onlyOwner
.Return:
Name | Type | Description |
---|---|---|
_owner | address | An owner address. |
Gets an address that can claim the owner role. It is used to transfer the ownership.
Return:
Name | Type | Description |
---|---|---|
_pendingOwner | address | A pending owner address. |
Last modified 6mo ago