Skip to content

Coordinator contract reference ​

VerityCoordinator. Source: verity-contracts/src/VerityCoordinator.sol.

Consumers ​

Function
requestRandomWords(bytes32 keyHash, uint256 subId, uint16 minConf, uint32 callbackGasLimit, uint32 numWords) → uint256 requestIdCalled 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) → uint128The 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 ​

EventFields
RandomWordsRequestedkeyHash (indexed), requestId (indexed), preSeed, subId, minimumRequestConfirmations, callbackGasLimit, numWords, reserved, sender (indexed)
RandomWordsFulfilledrequestId (indexed), outputSeed, subId (indexed), payment, success
RequestCanceledrequestId, 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 ​

ErrorMeaning
InvalidConsumer(subId, consumer)Add the consumer to the subscription first
InsufficientBalance(available, required)Fund the subscription; available = balance − reserved
InvalidRequestConfirmations, GasLimitTooBig, NumWordsTooBigParameter outside the allowed range
NoSuchProvingKeyWrong keyHash, or the lane was removed
RequestsPausedThe coordinator is paused
PendingRequestExistsCancelling a subscription with pending requests
NotTimedOutcancelRequest before the timeout

Testnet: PulseChain testnet v4. Unaudited software; do not use on mainnet yet.