Documentation ¶
Index ¶
- Constants
- func EstimateFeeJuels(callbackGasLimit uint32, maxGasPriceWei, weiPerUnitLink *big.Int) (*big.Int, error)
- func EstimateFeeWei(callbackGasLimit uint32, maxGasPriceWei *big.Int) (*big.Int, error)
- func MaybeSubtractReservedEth(q pg.Q, startBalance *big.Int, chainID uint64, subID *big.Int, ...) (*big.Int, error)
- func MaybeSubtractReservedLink(q pg.Q, startBalance *big.Int, chainID uint64, subID *big.Int, ...) (*big.Int, error)
- func New(cfg vrfcommon.Config, feeCfg vrfcommon.FeeConfig, l logger.Logger, ...) job.ServiceCtx
- func ToV2Commitments(commitments []RequestCommitment) []vrf_coordinator_v2.VRFCoordinatorV2RequestCommitment
- func ToV2PlusCommitments(commitments []RequestCommitment) []vrf_coordinator_v2plus.VRFCoordinatorV2PlusRequestCommitment
- func ToV2PlusProofs(proofs []VRFProof) []vrf_coordinator_v2plus.VRFProof
- func ToV2Proofs(proofs []VRFProof) []vrf_coordinator_v2.VRFProof
- type Config
- type CoordinatorV2_X
- type RandomWordsFulfilled
- type RandomWordsFulfilledIterator
- type RandomWordsRequested
- type RandomWordsRequestedIterator
- type RequestCommitment
- func (r *RequestCommitment) BlockNum() uint64
- func (r *RequestCommitment) CallbackGasLimit() uint32
- func (r *RequestCommitment) Get() any
- func (r *RequestCommitment) NativePayment() bool
- func (r *RequestCommitment) NumWords() uint32
- func (r *RequestCommitment) Sender() common.Address
- func (r *RequestCommitment) SubID() *big.Int
- type Subscription
- type SubscriptionCreated
- type SubscriptionCreatedIterator
- type VRFProof
Constants ¶
const ( // GasAfterPaymentCalculation is the gas used after computing the payment GasAfterPaymentCalculation = 21000 + 100 + 5000 + 2*2100 + 20000 - 4800 + 6685 // Positive static costs of argument encoding etc. note that it varies by +/- x*12 for every x bytes of non-zero data in the proof. // BatchFulfillmentIterationGasCost is the cost of a single iteration of the batch coordinator's // loop. This is used to determine the gas allowance for a batch fulfillment call. BatchFulfillmentIterationGasCost = 52_000 V2ReservedLinkQuery = `` /* 257-byte string literal not displayed */ V2PlusReservedLinkQuery = `` /* 269-byte string literal not displayed */ V2PlusReservedEthQuery = `` /* 267-byte string literal not displayed */ CouldNotDetermineIfLogConsumedMsg = "Could not determine if log was already consumed" )
const GasProofVerification uint32 = 200_000
GasProofVerification is an upper limit on the gas used for verifying the VRF proof on-chain. It can be used to estimate the amount of LINK or native needed to fulfill a request.
Variables ¶
This section is empty.
Functions ¶
func EstimateFeeJuels ¶
func EstimateFeeJuels(callbackGasLimit uint32, maxGasPriceWei, weiPerUnitLink *big.Int) (*big.Int, error)
EstimateFeeJuels estimates the amount of link needed to fulfill a request given the callback gas limit, the gas price, and the wei per unit link. An error is returned if the wei per unit link provided is zero.
func EstimateFeeWei ¶
EstimateFeeWei estimates the amount of wei needed to fulfill a request
func MaybeSubtractReservedEth ¶
func MaybeSubtractReservedEth(q pg.Q, startBalance *big.Int, chainID uint64, subID *big.Int, vrfVersion vrfcommon.Version) (*big.Int, error)
MaybeSubtractReservedEth figures out how much ether is reserved for other VRF requests that have not been fully confirmed yet on-chain, and subtracts that from the given startBalance, and returns that value if there are no errors.
func MaybeSubtractReservedLink ¶
func MaybeSubtractReservedLink(q pg.Q, startBalance *big.Int, chainID uint64, subID *big.Int, vrfVersion vrfcommon.Version) (*big.Int, error)
MaybeSubtractReservedLink figures out how much LINK is reserved for other VRF requests that have not been fully confirmed yet on-chain, and subtracts that from the given startBalance, and returns that value if there are no errors.
func New ¶
func New( cfg vrfcommon.Config, feeCfg vrfcommon.FeeConfig, l logger.Logger, ethClient evmclient.Client, chainID *big.Int, logBroadcaster log.Broadcaster, q pg.Q, coordinator CoordinatorV2_X, batchCoordinator batch_vrf_coordinator_v2.BatchVRFCoordinatorV2Interface, vrfOwner vrf_owner.VRFOwnerInterface, aggregator *aggregator_v3_interface.AggregatorV3Interface, txm txmgr.TxManager, pipelineRunner pipeline.Runner, gethks keystore.Eth, job job.Job, mailMon *utils.MailboxMonitor, reqLogs *utils.Mailbox[log.Broadcast], reqAdded func(), respCount map[string]uint64, headBroadcaster httypes.HeadBroadcasterRegistry, deduper *vrfcommon.LogDeduper, ) job.ServiceCtx
func ToV2Commitments ¶
func ToV2Commitments(commitments []RequestCommitment) []vrf_coordinator_v2.VRFCoordinatorV2RequestCommitment
func ToV2PlusCommitments ¶
func ToV2PlusCommitments(commitments []RequestCommitment) []vrf_coordinator_v2plus.VRFCoordinatorV2PlusRequestCommitment
func ToV2PlusProofs ¶
func ToV2PlusProofs(proofs []VRFProof) []vrf_coordinator_v2plus.VRFProof
func ToV2Proofs ¶
func ToV2Proofs(proofs []VRFProof) []vrf_coordinator_v2.VRFProof
Types ¶
type Config ¶
type Config interface { MinimumRequestConfirmations() uint16 MaxGasLimit() uint32 GasAfterPaymentCalculation() uint32 StalenessSeconds() uint32 }
func NewV2Config ¶
func NewV2Config(config vrf_coordinator_v2.GetConfig) Config
func NewV2PlusConfig ¶
func NewV2PlusConfig(config vrf_coordinator_v2plus.SConfig) Config
type CoordinatorV2_X ¶
type CoordinatorV2_X interface { Address() common.Address ParseRandomWordsRequested(log types.Log) (RandomWordsRequested, error) RequestRandomWords(opts *bind.TransactOpts, keyHash [32]byte, subID *big.Int, requestConfirmations uint16, callbackGasLimit uint32, numWords uint32, payInEth bool) (*types.Transaction, error) AddConsumer(opts *bind.TransactOpts, subID *big.Int, consumer common.Address) (*types.Transaction, error) CreateSubscription(opts *bind.TransactOpts) (*types.Transaction, error) GetSubscription(opts *bind.CallOpts, subID *big.Int) (Subscription, error) GetConfig(opts *bind.CallOpts) (Config, error) ParseLog(log types.Log) (generated.AbigenLog, error) OracleWithdraw(opts *bind.TransactOpts, recipient common.Address, amount *big.Int) (*types.Transaction, error) LogsWithTopics(keyHash common.Hash) map[common.Hash][][]log.Topic Version() vrfcommon.Version RegisterProvingKey(opts *bind.TransactOpts, oracle common.Address, publicProvingKey [2]*big.Int) (*types.Transaction, error) FilterSubscriptionCreated(opts *bind.FilterOpts, subID []*big.Int) (SubscriptionCreatedIterator, error) FilterRandomWordsRequested(opts *bind.FilterOpts, keyHash [][32]byte, subID []*big.Int, sender []common.Address) (RandomWordsRequestedIterator, error) FilterRandomWordsFulfilled(opts *bind.FilterOpts, requestID []*big.Int, subID []*big.Int) (RandomWordsFulfilledIterator, error) TransferOwnership(opts *bind.TransactOpts, to common.Address) (*types.Transaction, error) RemoveConsumer(opts *bind.TransactOpts, subID *big.Int, consumer common.Address) (*types.Transaction, error) CancelSubscription(opts *bind.TransactOpts, subID *big.Int, to common.Address) (*types.Transaction, error) GetCommitment(opts *bind.CallOpts, requestID *big.Int) ([32]byte, error) Migrate(opts *bind.TransactOpts, subID *big.Int, newCoordinator common.Address) (*types.Transaction, error) FundSubscriptionWithEth(opts *bind.TransactOpts, subID *big.Int, amount *big.Int) (*types.Transaction, error) }
CoordinatorV2_X is an interface that allows us to use the same code for both the V2 and V2Plus coordinators.
func NewCoordinatorV2 ¶
func NewCoordinatorV2(c *vrf_coordinator_v2.VRFCoordinatorV2) CoordinatorV2_X
func NewCoordinatorV2Plus ¶
func NewCoordinatorV2Plus(c *vrf_coordinator_v2plus.VRFCoordinatorV2Plus) CoordinatorV2_X
type RandomWordsFulfilled ¶
type RandomWordsFulfilled interface { RequestID() *big.Int Success() bool SubID() *big.Int Payment() *big.Int Raw() types.Log }
func NewV2PlusRandomWordsFulfilled ¶
func NewV2PlusRandomWordsFulfilled(event *vrf_coordinator_v2plus.VRFCoordinatorV2PlusRandomWordsFulfilled) RandomWordsFulfilled
func NewV2RandomWordsFulfilled ¶
func NewV2RandomWordsFulfilled(event *vrf_coordinator_v2.VRFCoordinatorV2RandomWordsFulfilled) RandomWordsFulfilled
type RandomWordsFulfilledIterator ¶
type RandomWordsFulfilledIterator interface { Next() bool Error() error Close() error Event() RandomWordsFulfilled }
func NewV2PlusRandomWordsFulfilledIterator ¶
func NewV2PlusRandomWordsFulfilledIterator(it *vrf_coordinator_v2plus.VRFCoordinatorV2PlusRandomWordsFulfilledIterator) RandomWordsFulfilledIterator
func NewV2RandomWordsFulfilledIterator ¶
func NewV2RandomWordsFulfilledIterator(it *vrf_coordinator_v2.VRFCoordinatorV2RandomWordsFulfilledIterator) RandomWordsFulfilledIterator
type RandomWordsRequested ¶
type RandomWordsRequested interface { Raw() types.Log NumWords() uint32 SubID() *big.Int MinimumRequestConfirmations() uint16 KeyHash() [32]byte RequestID() *big.Int PreSeed() *big.Int Sender() common.Address CallbackGasLimit() uint32 NativePayment() bool }
func NewV2PlusRandomWordsRequested ¶
func NewV2PlusRandomWordsRequested(event *vrf_coordinator_v2plus.VRFCoordinatorV2PlusRandomWordsRequested) RandomWordsRequested
func NewV2RandomWordsRequested ¶
func NewV2RandomWordsRequested(event *vrf_coordinator_v2.VRFCoordinatorV2RandomWordsRequested) RandomWordsRequested
type RandomWordsRequestedIterator ¶
type RandomWordsRequestedIterator interface { Next() bool Error() error Close() error Event() RandomWordsRequested }
func NewV2PlusRandomWordsRequestedIterator ¶
func NewV2PlusRandomWordsRequestedIterator(it *vrf_coordinator_v2plus.VRFCoordinatorV2PlusRandomWordsRequestedIterator) RandomWordsRequestedIterator
func NewV2RandomWordsRequestedIterator ¶
func NewV2RandomWordsRequestedIterator(it *vrf_coordinator_v2.VRFCoordinatorV2RandomWordsRequestedIterator) RandomWordsRequestedIterator
type RequestCommitment ¶
type RequestCommitment struct { VRFVersion vrfcommon.Version V2 vrf_coordinator_v2.VRFCoordinatorV2RequestCommitment V2Plus vrf_coordinator_v2plus.VRFCoordinatorV2PlusRequestCommitment }
func NewRequestCommitment ¶
func NewRequestCommitment(val any) RequestCommitment
func (*RequestCommitment) BlockNum ¶
func (r *RequestCommitment) BlockNum() uint64
func (*RequestCommitment) CallbackGasLimit ¶
func (r *RequestCommitment) CallbackGasLimit() uint32
func (*RequestCommitment) Get ¶
func (r *RequestCommitment) Get() any
func (*RequestCommitment) NativePayment ¶
func (r *RequestCommitment) NativePayment() bool
func (*RequestCommitment) NumWords ¶
func (r *RequestCommitment) NumWords() uint32
func (*RequestCommitment) Sender ¶
func (r *RequestCommitment) Sender() common.Address
func (*RequestCommitment) SubID ¶
func (r *RequestCommitment) SubID() *big.Int
type Subscription ¶
type Subscription interface { Balance() *big.Int EthBalance() *big.Int Owner() common.Address Consumers() []common.Address Version() vrfcommon.Version }
func NewV2PlusSubscription ¶
func NewV2PlusSubscription(event vrf_coordinator_v2plus.GetSubscription) Subscription
func NewV2Subscription ¶
func NewV2Subscription(event vrf_coordinator_v2.GetSubscription) Subscription
type SubscriptionCreated ¶
func NewV2PlusSubscriptionCreated ¶
func NewV2PlusSubscriptionCreated(event *vrf_coordinator_v2plus.VRFCoordinatorV2PlusSubscriptionCreated) SubscriptionCreated
func NewV2SubscriptionCreated ¶
func NewV2SubscriptionCreated(event *vrf_coordinator_v2.VRFCoordinatorV2SubscriptionCreated) SubscriptionCreated
type SubscriptionCreatedIterator ¶
type SubscriptionCreatedIterator interface { Next() bool Error() error Close() error Event() SubscriptionCreated }
func NewV2PlusSubscriptionCreatedIterator ¶
func NewV2PlusSubscriptionCreatedIterator(it *vrf_coordinator_v2plus.VRFCoordinatorV2PlusSubscriptionCreatedIterator) SubscriptionCreatedIterator
func NewV2SubscriptionCreatedIterator ¶
func NewV2SubscriptionCreatedIterator(it *vrf_coordinator_v2.VRFCoordinatorV2SubscriptionCreatedIterator) SubscriptionCreatedIterator
type VRFProof ¶
type VRFProof struct { VRFVersion vrfcommon.Version V2 vrf_coordinator_v2.VRFProof V2Plus vrf_coordinator_v2plus.VRFProof }
func FromV2PlusProof ¶
func FromV2PlusProof(proof vrf_coordinator_v2plus.VRFProof) VRFProof
func FromV2Proof ¶
func FromV2Proof(proof vrf_coordinator_v2.VRFProof) VRFProof