1. Foundry project setup
1
Create a Foundry project
Create a Foundry project (or configure an existing one) following our Foundry guide.
Get Started with Foundry
Learn how to install and configure foundry-zksync for Abstract.
2
Install Absmate
Install Absmate; a collection of helpful utilities for building contracts on Abstract.
3
Configure remappings
Add the following to your
remappings.txt
file to use Absmate’s contracts.remappings.txt
2. Create a game contract
Create a contract that requests and receives random numbers by extendingVRNGConsumer
.
src/CoinFlipGame.sol
3. Test with mock contracts
Test your game contract behaviour with Absmate’s mock contracts.1
Create a test contract
Use the
MockVRNGSystem
contract to mock the VRNG system in your tests.Pass its contract address to your game contract, by providing it to the _setVRNG
function (here we do it via a constructor argument to the CoinFlipGame
contract).test/CoinFlipGameTest.t.sol
2
Test your contract with request/fulfill pattern mocks
Mock the two-phase request/fulfill pattern:
- Request a random number from the vRNG service.
- Mock the callback function execution using
randomNumberCallback
.
test/CoinFlipGameTest.t.sol
3
Run your tests
Verify your contract behaves as expected.
See Foundry testing for more details.
4. Deploy your contract
1
Create a deploy script
Create a deploy script to deploy your game contract with the Proof of Play vRNG contract address based on the chain ID.
script/DeployCoinFlipGame.s.sol
2
Run the deploy script
Deploy your contract to Abstract using the deploy script.
3
Contact the Proof of Play team
The Proof of Play vRNG contracts currently require your contract address to be whitelisted to enable the
randomNumberCallback
function to be called.Contact the Proof of Play team to whitelist your smart contract address.Contact the Proof of Play team
Contact the Proof of Play team to whitelist your smart contract address.