Skip to main content
For more information, download the code here

Setup

1. Install dependencies

First, install forge
curl -L https://foundry.paradigm.xyz | bash
Then you can use the command shown in the output of the install (source ~/.zshenv or whatever your shell environment is) or just open a new terminal window and run:
foundryup
which will finish installing forge. Then, you can run:
forge install
which will finish updating the dependencies in the repo. Additionally install pinata cli, the ipfs upload manager (more on this in the next section).
curl -fsSL https://cli.pinata.cloud/install | bash
Finally, create the directory for uploading the policy files (make sure to put it in the root of this repo and use this directory name!)
mkdir policy-files

2. Get Your Pinata Credentials

  1. Go to Pinata
  2. Create a new API key. If you don’t just make an admin key, make sure the API key has write permissions for files and read permission for gateways.
  3. Copy the API Key, API Secret, and JWT
  4. Login in your terminal via pinata auth
  5. Note your gateway domain (e.g., your-subdomain.mypinata.cloud), this is in a different tab than API keys

3. Configure Environment Variables

Create a file .env by copying and renaming .env.example
cp .env.example .env
Update your .env file with your Pinata credentials:
# Pinata IPFS Configuration
PINATA_API_KEY=your_pinata_api_key_here
PINATA_API_SECRET=your_pinata_api_secret_here
PINATA_JWT=your_pinata_jwt_here
PINATA_GATEWAY=your_pinata_gateway_domain_here
Additionally fill in the values for deploying the contract. Note that the private key needs to correspond to an account with some ether for deploying the policy contract. Additionally, the RPC_URL variable is chain dependent. Make sure it applies to the deployment you’re making (either to sepolia testnet or mainnet).
# Forge config parameters
PRIVATE_KEY=your_funded_deployer_address_private_key
RPC_URL=make_sure_this_matches_the_chain_you're_deploying_to

4. Provide Policy Files

Put your policy files in the policy-files folder. You can look in policy-examples for some example files to start you off or read the following quickstart guide. See Policy Files for an explanation of what each file is for.

Usage

Deploy your Policy contract

If everything in policy-files is good to go, you can deploy your sample policy contract using the following command.
make upload-and-deploy-policy
After these inputs, the script will deploy the contract. If successful you should be greeted with an output that looks like:
[⠊] Compiling...
No files changed, compilation skipped
Script ran successfully.

== Logs ==
  {
  "policyFactory": "0xd949169c6eAc4D62D56a07756Ca48054705e9FE8",
  "policyFactoryImpl": "0xaafC65C4dBd528cD237d3faF3fACb50F19142F0a",
  "policy": "0x7a3C8Bb03B7F2BFe270c53643d7133D378fA8b57",
  "policyImplementation": "0x7eBA0f843B63b4D531e8c8833F0Ae4bcB27aF61B",
  "policyDataFactory": "0x81121D4F4E31040971c135701b09D3852f1278fe",
  "policyDataFactoryImpl": "0xa0268676b274B47ADe84E3eCd28cC2A90801dca2",
  "policyData": "0x33e8D1aEAF343FaE5427bCc69d995a2338Baee9B",
  "policyDataImplementation": "0x4dcd461a2E3114002f381513Ff441000D4840B4e"
}
From this output, copy the value marked "policy": "0x7a3C8Bb03B7F2BFe270c53643d7133D378fA8b57", (will show your contract address instead of

Deploy your PolicyClient contract

After that, you can deploy the policy client:
make deploy-client
It will ask you for the policy address created in the first step and also prompt you to confirm the chainID.