Development happens locally against a local forked version of the blockchain. We do not use testnets.
- git
- You'll know you did it right if you can run
git --version
and you see a response likegit version x.x.x
- You'll know you did it right if you can run
- Nodejs
- You'll know you've installed nodejs right if you can run
node --version
and get an ouput like:vx.x.x
- You'll know you've installed nodejs right if you can run
- Yarn
- You'll know you've installed yarn right if you can run
yarn --version
And get an output like:x.x.x
- You'll know you've installed yarn right if you can run
- Clone the repo & install dependencies
git clone https://github.com/BeanstalkFarms/Beanstalk
cd Beanstalk
yarn
- Install pre-commit git hooks and setup your workspace
yarn bootstrap
There are cross-project dependencies you may need to be aware of. For ex, the UI uses the SDK, which uses the SDK-Core. The dependencies need to be built before they can be used by the parent project. When you ran yarn bootstrap
, this built everything for you, but there may be times when you need to do this manually.
Easiest way to ensure everything is built:
cd {REPO_ROOT}
yarn
This will start building all the dependencies in reverse order. See below to work with different projects.
If you're not working on the contracts, you don't need to do anything with the protocol. If you're using anvil (see here), it will use a copy of mainnet, including all the deployed contracts.
If you are developing contracts, see the README.md
in /protocol
for more details getting set up.
We elect to use anvil
instead of hardhat
for local node forking as anvil
is considerably faster than hardhat
and properly caches the blockchain locally.
- Install Foundry with
curl -L https://foundry.paradigm.xyz | bash
and reopen your terminal - Run
foundryup
to ensure you have downloaded the latest version - Start a locally forked node with the following command:
# optionally add
# --fork-block-number <BLOCK_NUMBER>
# if you want a specific point in time
anvil --fork-url <FORK_RPC> --chain-id 1337 --block-time 12
When anvil starts, you will see a list of Available Accounts and their Private Keys. We recommend using Account #0 (0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
) and adding its private key to metamtask. (The bean
cli defaults to this address).
In this repo there is also our Beanstalk development CLI tool. To run:
# no install, from anywhere inside the monorepo:
yarn g:bean --help
# OR.. installed on your system
npm i -g @beanstalk/cli
bean --help
Some examples of what you can do with the bean cli:
- Get balances:
yarn g:bean balance
- Give yourself 50K of each token:
yarn g:bean setbalance
- Set balance of a specific token:
yarn g:bean setbalance -t BEAN -m 3000
- Make BEAN price above $1:
yarn g:bean setprice 20 30
- Fast forward season into future:
yarn g:bean sunrise --force
yarn g:bean --help
for all options
By combining these commands, you should be able to put a beanstalk account in pretty much any state desired.
Start the UI with yarn ui:start