Set Up the Development Environment

Before diving into the various features of the Blockdaemon DeFi API, we first need to setup our development environment with some example scripts. The following guides use the typescript SDK as well as a generic REST API.

We assume basic knowledge of node.js and your operating system’s command line interface.

Before we delve into the code, let’s set some groundwork:

  1. Contact us to get the API key.
  2. Clone our DeFi API example project: git clone
  3. Enter into the project directory: cd defi-api-examples.
  4. Follow the setup instructions in the The explores a set of functionalities such as obtaining chain information, token information, and conducting a swap. Please refer to the accompanying guides for more details.

All scripts in the DeFi API example project rely on common code. For the full code please refer to

The common initialisation code reads and validates the entries in your .env file and exports a few useful objects:

  • logger is an instance of a logger for consistent logging throughout the example scripts.
  • apiConfig is an instance of the configuration object required by the DeFi API typescript SDK. It contains the api endpoint as well as the api key from your .env file.
  • optimismWallet and polygonWallet can be used to sign and broadcast transactions using the to sign and broadcast transactions using the ethers library and the Blockdaemon RPC API.

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.