This repo is a collection of code samples to showcase how to execute different operations on Balanced.
To be able to run the code samples, first clone the repo and then install the required dependencies:
git clone https://github.com/balancednetwork/balanced-examples.git
cd balanced-examples
npm installThe sample scripts can run in both testnet and mainnet environments. To switch between the two, set the NETWORK environment variable to either testnet or mainnet (default is testnet).
For this create a .env file in the root of the project and add the following line:
NETWORK=testnetAlso setup a PRIVATE_KEY environment variable in the .env file with the private key of the account you want to use to sign transactions.
NETWORK=testnet
PRIVATE_KEY=0x...If no private key is provided, the scripts that require signing transactions will fail.
The following scripts are available:
- Query a pool price
- Make ICON-ICON swap (ICX to TOKEN)
- Make ICON-ICON swap (TOKEN to TOKEN)
- Make ICON-ICON swap (TOKEN to ICX)
- Make ICON-SPOKE swap (ICX to NATIVE on SPOKE)
- Make ICON-SPOKE swap (TOKEN on ICON to TOKEN on SPOKE)
- Make SPOKE-SPOKE swap (NATIVE coin on source chain)
- Make SPOKE-SPOKE swap (TOKEN on source chain)