PackVRF
Functionality available for contracts that implement the
IPackVRFDirect
interface;
the Chainlink VRF variation of the pack interface.
addPackOpenEventListener
Create an event listener that calls a callback
function whenever a pack is opened on the contract.
const unsubscribe = await contract.vrf.addPackOpenEventListener(
(packId, openerAddress, rewards) => {
console.log(
`Pack ${packId} was opened by ${openerAddress} and contained:, ${rewards})`,
);
},
);
Configuration
canClaimRewards
Check if a specific wallet can claim rewards after opening a pack.
const canClaim = await contract.vrf.canClaimRewards("{{wallet_address}}");
Configuration
claimRewards
Claim the rewards from an opened pack.
Use canClaimRewards
to check if the wallet can claim rewards before calling this method.
const txResult = await contract.vrf.claimRewards();
getLinkBalance
Get the LINK balance of the contract.
const linkBalance = await contract.vrf.getLinkBalance();
Configuration
open
Open a pack using Chainlink VRFs random number generation.
const result = await contract.vrf.open("{{token_id}}", "{{amount}}");
Configuration
openAndClaim
Open a pack and claim the rewards.
This function will start the flow of opening a pack. The rewards will be granted automatically to the connected address after VRF request is fulfilled.
This is essentially a shortcut for calling open
and claimRewards
in sequence.
const txResult = await contract.vrf.openAndClaim("{{token_id}}", "{{amount}}");
Configuration
transferLink
Transfer LINK to this contract.
Note: the wallet that initiates this transaction must have the amount of LINK specified in the amount
parameter.
const txResult = await contract.vrf.transferLink("{{amount}}");