Tutorial: Importing Testnet Tokens for Use in Soroban
The Stellar CLI used to be called
soroban. Commands on this page use the current stellar name, so if you are reading an older copy of the script you may see soroban lab token id where this page shows stellar contract id asset. They do the same thing.Introduction
This tutorial will guide you through the process of importing testnet tokens, specifically Stellar Classic assets, and wrapping them for use with Soroban. We will use a Bash script to automate this process.Prerequisites
- Basic understanding of blockchain concepts and the Stellar network.
- A system with Bash shell.
- The
jqtool installed for JSON processing. - The Stellar CLI installed.
Overview of the Script
The provided Bash script performs several key functions:- Reading and merging asset lists from JSON files.
- Wrapping each asset to be compatible with Soroban.
- Updating a token list with new Soroban addresses.
Script Breakdown
-
Setting Environment Variables and Directories
ASSETS_DIRECTORYandGENERATED_STELLAR_ASSETSpoint to the JSON files containing asset information.known_stellar_classic_assets.jsonexample
- Reading and Merging Asset Lists
-
Wrapping Assets
This is the critical line where each asset is wrapped. The
stellar contract id assetcommand deploys the built in Stellar Asset Contract for the asset and returns its contract address, which is how Soroban contracts reach that same asset. - Looping Through Assets The script loops through each asset in the merged list, wrapping them and updating the token list with their new Soroban addresses.
-
Updating the Token List
The updated token addresses are saved back to the
TOKENS_DIRECTORY, ensuring that the assets are now usable in Soroban. - Error Handling and Outputs The script includes checks to handle errors and provide informative output messages throughout the process.
Running the Script
- Ensure you have the necessary JSON files in the specified directories.
- Run the script in your Bash shell:
Replace
[network]with the desired network type (e.g.,testnet).