A collection of on-chain programs that work together to support governance over Tokr's DeFi products.
Running npm install will install all packages throughout the repo. It will also setup the CLIs for governance, permissioned list, identity verification and cap-table.
$ npm install
Running the following command will build all programs referenced in the Anchor.toml
file in the root directory.
$ npm run build
Deploying programs is a bit tricky right now for Anchor programs. Everytime the target directory is deleted or someone new joins the team the locally built programs will have different IDs. WIP to write scripts that make this much easier and there is a new PR to anchor for adding the ability to pass a keypair rather than using the generated ones. These instructions will likely change as soon as that functionality is available through the Anchor CLI.
IMPORTANT Deploying to different environments you will need to update the program id in lib.rs
by replacing the base58 key declared at the top of the file with the correct id for the environment being deployed to. After updating this variable you will need to run anchor build
before deploying.
$ npm run deploy
Deployment should only have to happen once, unless there is a reason to create a new version of the program and keep the old one running. CAUTION These steps are very important for the first deployment:
- Run npm build
- Replace the contents of
target/deploy/identity_verification-keypair.json
with the contents of our production version of the keypairidv2F375xYuz2K7a7LxcrkhgWbPsJgpuWD3XLW1AFdD.json
orCCzEwDHqNqq4KL4srnRKQeQ7P9Aa1uoAQmkz1kWFc2rd.json
for mainnet and devnet respectively. - Replace the contents of
target/deploy/spl_governance-keypair.json
with the contents of our production version of the keypairgovB89Q9nod6CYMjC2zVhefv4oW1zWrYQGfU7gAsrnr.json
or5WJNeGKQQJMaTCPgtXhmsiEK4bA6dLT94smLFmTU8Gh9.json
for mainnet and devnet respectively.
$ anchor build
$ anchor deploy --provider.cluster [mainnet | devnet]
IMPORTANT Upgrading programs on different environments you will need to update the program id in lib.rs
by replacing the base58 key declared at the top of the file with the correct id for the environment being deployed to. After updating this variable you will need to run anchor build
before upgrading.
Once the programs are initially deployed we'll want to keep the same program ids so we'll need to make sure we only run upgrade in this scenario.
Devnet
$ npm run upgrade:governance:devnet
$ npm run upgrade:identity-verification:devnet
Mainnet
$ npm run upgrade:governance:mainnet
$ npm run upgrade:identity-verification:mainnet
- Solana tool-chain
- Tokr CLI
The following steps will get your machine up and running with the tokr programs.
Here we're making sure that our local config is pointing to http://localhost:8899 where our cluster is running.
$ solana config set --url localhost
This starts the localnet cluster of solana. Running with --reset
will basically bring you back to the genesis hash, like a system reset of sorts.
$ solana-test-validator [--reset]
Open a new terminal window and run the following command. It will esentially set up a tail for the logs which are useful during development.
$ solana logs
We'll need to create a mint/token for what we'll call USDC in localnet (and devnet). This is because USDC does not exist in our cluster as it does on mainnet. Make not of the Mint Address, we'll need this for a later step.
$ tokr-helper create-spl-token --amount 1000000
This will build out programs (governance and identity verification)
$ npm run build
Next we'll deploy these programs out to devnet. Make not of the program IDs as we'll need those later.
$ npm run deploy
You'll need to airdrop funds to whoever you are wanting to make the delegate of the DAO, These will be used for fees, but it also tells localnet that this is a real user account owned by the system program and not a PDA.
$ solana airdrop 10 [DELEGATE_PUBLIC_KEY]
Copy and paste the example-config.json
file in the /governance/cli
directory rename it and place it somewhere on you machine outside of the repo.
This config file is what we use to determine how to set up the DAO. The file contents look like this.
{
"cluster": "http://localhost:8899",
"owner": "~/.config/solana/id.json",
"delegate": "~/.config/solana/id.json",
"name": "Realm 2",
"governanceProgramId": "7cjMfQWdJ9Va2pjSZM3D9G2PGCwgWMzbgcaVymCtRVQZ",
"usdcMint": "4vLoappqntEvnxT1uSATbjt1nPMG2q6HjhHVgyuxxAaW",
"governance": {
"voteThresholdPercentage": 100,
"minCommunityTokensToCreateProposal": 10000000,
"minInstructionHoldUpTime": 0,
"maxVotingTime": 259250,
"voteTipping": 0,
"proposalCoolOffTime": 0,
"minCouncilTokensToCreateProposal": 1
}
}
You will need to replace the values of the governance program id to your localnet program id as well as whatever the USDC token mint was from above instructions.
$ tokr-governance \
create-dao \
-i ~/Desktop/config.json