This repository comprise a set of scripts that leverages BD's DEFI API. The script collection guides the creation of an application that leverages the DEFI API and has cross-chain token transfer capabilities.
This is a Typescript project. Npm as package manager and node. Tested with npm v10.2.4, node 21.5.0. We recommend using nvm for node version management.
-
Install node 21.5.0 (using nvm:
nvm install 21.5.0 && nvm use 21.5.0
) -
Install the dependencies with
npm install
. -
Copy the environment variables with
cp .env.example .env
. -
Generate a Blockdaemon API Key.
-
Populate the variables, including your Blockdaemon API Key (BLOCKDAEMON_API_KEY), the private key that you will be using to sign transactions in the form of a mnemonic (MNEMONIC), the SENDER_ADDRESS (that will sign transactions using the MNEMONIC) and RECEIVER_ADDRESS (can be the same).
-
Run the scripts with
npx ts-node src/main/scripts/SCRIPT.ts
, whereSCRIPT
can be:
do-swap
(performs a cross-chain token transfer from sender to receiver based on the first received route);get-approvals
(gets the status of an approval)get-chains
(gets the list of supported chains)get-prices
(gets token prices from a wide range of blockchains)get-routes
(gets a set of routes that satisfy a swap);get-status
(gets the status for a transaction);get-tokens-by-tag
(gets the list of supported tokens by specified tag)get-tokens
(gets the list of supported tokens)make-approvals
(creates a spend approval for an ERC20 token)sign-and-broadcast-transaction
(signs and broadcasts a transaction to the blockchain).
For issues related to the code in this repository, please use the issues tracker.
Contact us through email or our support page for any issues, bugs, or assistance you may need.