Skip to content

starwalker00/foundry-chainlink

Repository files navigation

foundry-chainlink

Foundry project that demonstrates usage of Chainlink VRF and Chainlink Keepers on Polygon Mumbai Testnet.

VRF

Chainlink VRF generates one or more random values and cryptographic proof of how those values were determined. VRF v2 requests receive funding from subscription accounts. Users pre-pay for VRF v2 so they don't have to provide funding each time their application requests randomness. For Chainlink VRF v2 to fulfill your requests, you must maintain a sufficient amount of LINK in your subscription balance.

End-to-end diagram

Setup VRF Subscriber

Chainlink VRF Subscription Manager

  • Create a subscription
  • Fund it with LINK token
  • Add consumer contracts

Install Chainlink contracts

forge install https://github.com/smartcontractkit/chainlink-brownie-contracts

Install OpenZeppelin contracts

forge install openzeppelin/openzeppelin-contracts

Chainlink VRF Subscription Manager

Mumbai Transactions and contracts

Test Wallet : https://mumbai.polygonscan.com/address/0x235596f35fdeac45a59bf38640dd68f19a85de39

VRF

Creation of a subscription : https://mumbai.polygonscan.com/tx/0x5996624f36c9c925df910e35ab330060195c77d907b1b978a67cb7770b7a8b3c

Add funds (3 LINK) to subscription : https://mumbai.polygonscan.com/tx/0xd85fa9480d93506b07214d2408b2584794c6f77ad654cc74958bc573cfc950ca

Chainlink subscription contract : https://mumbai.polygonscan.com/address/0x7a1bac17ccc5b313516c5e16fb24f7659aa5ebed

Add VRF consumer contract : https://mumbai.polygonscan.com/tx/0x65651dd80d754980cc06264b66cd771dff31eab5cda3ccb6465370d6f63adfe6

Keeper

Setup VRF Keeper

Chainlink VRF Keeper Manager

Register CRON job : https://mumbai.polygonscan.com/tx/0x64b82e5dde15194e716d77d9f73e21471f9ecee9dfa649676abf6afcfd84376d

solidity dates : https://soliditytips.com/articles/solidity-dates-time-operations/

OpenZeppelin utils including data types : https://docs.openzeppelin.com/contracts/3.x/api/utils

Foundry cheatcodes : https://book.getfoundry.sh/cheatcodes/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published