Appearance
Coordinator contract reference
VerityCoordinator. Source: verity-contracts/src/VerityCoordinator.sol.
Consumers
| Function | |
|---|---|
requestRandomWords(bytes32 keyHash, uint256 subId, uint16 minConf, uint32 callbackGasLimit, uint32 numWords) → uint256 requestId | Called by a consumer of subId. Reserves the max cost. |
pendingRequestExists(uint256 requestId) → bool | |
cancelRequest(uint256 requestId, RequestCommitment rc) | After requestTimeoutBlocks; consumer or subscription owner. Refunds the reservation. |
computeRequestId(bytes32 keyHash, address sender, uint256 subId, uint64 nonce) → (requestId, preSeed) | preSeed includes the coordinator address |
estimateRequestCost(bytes32 keyHash, uint32 callbackGasLimit) → uint128 | The reservation |
Your contract receives rawFulfillRandomWords(uint256 requestId, uint256[] words) from VerityConsumerBase, which forwards to your fulfillRandomWords.
Subscriptions
createSubscription, fundSubscription (payable), addConsumer, removeConsumer, cancelSubscription(subId, to), requestSubscriptionOwnerTransfer, acceptSubscriptionOwnerTransfer, migrate(subId, newCoordinator), and getSubscription(subId) → (balance, reserved, pendingRequests, owner, consumers).
Operators and owner
withdraw(to), s_withdrawable(operator), registerProvingKey(pk, operator, maxGasPrice), deregisterProvingKey(pk), setConfig(Config), getConfig(), setPaused(bool), pause() (guardian), setGuardian, withdrawProtocolFees(to), setMigrationTarget, setMigrationSource, onMigration(data) (v2.2+: receives a migrated subscription and assigns a new subId; event SubscriptionMigrated(subId, oldCoordinator, oldSubId)).
Events
| Event | Fields |
|---|---|
RandomWordsRequested | keyHash (indexed), requestId (indexed), preSeed, subId, minimumRequestConfirmations, callbackGasLimit, numWords, reserved, sender (indexed) |
RandomWordsFulfilled | requestId (indexed), outputSeed, subId (indexed), payment, success |
RequestCanceled | requestId, subId |
Subscription* | created, funded, consumer added/removed, owner transfer, canceled |
outputSeed is the VRF output. The consumer received keccak256(abi.encode(outputSeed, i)) for each word i.
Common errors
| Error | Meaning |
|---|---|
InvalidConsumer(subId, consumer) | Add the consumer to the subscription first |
InsufficientBalance(available, required) | Fund the subscription; available = balance − reserved |
InvalidRequestConfirmations, GasLimitTooBig, NumWordsTooBig | Parameter outside the allowed range |
NoSuchProvingKey | Wrong keyHash, or the lane was removed |
RequestsPaused | The coordinator is paused |
PendingRequestExists | Cancelling a subscription with pending requests |
NotTimedOut | cancelRequest before the timeout |