Set Up Your Local Environment

Local developmentarrow-up-right

If you want to do any local development we recommend installing Node.jsarrow-up-right and Foundryarrow-up-right. We are going to be using Node.js for package management and running javascript in the tutorials, but it is not required. You can use any development environment that supports javascript and npm packages.

We are going to be using Foundry to start local forks for existing chains. You don't have to use Foundry to do this, you can use any tool you want to do this, but we recommend Foundry.

For Linux or macOS everything should work out of the box, if you are using Windows, then we recommend installing everything from within WSL2 and expect some quirks. Remember to reopen your shell after running the first line.

  1. Node.jsarrow-up-right v18+, we recommend installation through nvmarrow-up-right, with Yarn 2arrow-up-right enabled:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# Reopen shell
nvm install --lts
# Enable the Yarn 2 package manager
corepack enable
  1. Foundryarrow-up-right development framework for Ethereum:

curl -L https://foundry.paradigm.xyz | bash
# Reopen shell
foundryup

Create tutorial folderarrow-up-right

The tutorials can be run in an isolated folder where you install Mangrove dependencies.

Open a terminal and run the following commands:

Install dependenciesarrow-up-right

Now install the following dependencies:

Inside the tutorial folder, create a .env file. This will hold the secrets such as private key and API keys. Here we describe it in general, but the next section provides some working example values.

The file should typically look as follows (with <...> replaced by proper values) - for instance you need a RPC URL from, e.g., Infuraarrow-up-right or Alchemyarrow-up-right, and an EOA with a private key. Note, there are other ways to provide secrets, but this is what we do in the tutorials.

If you do not have a RPC URL, there exists free RPC URLs, some examples can be found here: ChainListarrow-up-right - note that they can be unstable and in that case we recommend creating your own through the listed providers.

The tutorials can be run directly on networks where Mangrove is deployed (see Addresses). However on a real network you will spend real tokens, so we recommend starting on test networks with a test account.

To further speed things up we run tutorials on a local fork of a chain using Foundry's anvil tool.

How to fork an existing chain

This starts a new chain on with a local url of http://127.0.0.1:8545. You can read more about the anvil command herearrow-up-right, if you are interested.

When anvil starts up, it creates 10 test accounts, with some native tokens. If you do not have a real account on the chain, you can always use these accounts. Here is an example of a .env file that uses the first anvil account, a demo RPC URL and with a LOCAL URL.

Tip :

The demo RPC URLs are unstable, so if you cannot connect then create your own or use a different one.

Previous: What is the Strat Library? arrow-up-right

Last updated

Was this helpful?