Skip to main content

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 jq tool 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.
you can find this script here setup_stellar_classic_assets.sh

Script Breakdown

  1. Setting Environment Variables and Directories
    • ASSETS_DIRECTORY and GENERATED_STELLAR_ASSETS point to the JSON files containing asset information.
    • known_stellar_classic_assets.json example
  2. Reading and Merging Asset Lists
These commands extract the token lists from JSON files and merge them.
  1. Wrapping Assets
    This is the critical line where each asset is wrapped. The stellar contract id asset command deploys the built in Stellar Asset Contract for the asset and returns its contract address, which is how Soroban contracts reach that same asset.
  2. 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.
  3. Updating the Token List The updated token addresses are saved back to the TOKENS_DIRECTORY, ensuring that the assets are now usable in Soroban.
  4. Error Handling and Outputs The script includes checks to handle errors and provide informative output messages throughout the process.

Running the Script

  1. Ensure you have the necessary JSON files in the specified directories.
  2. Run the script in your Bash shell:
    Replace [network] with the desired network type (e.g., testnet).

Conclusion

Following these steps, you can efficiently wrap Stellar Classic assets for use with Soroban. This script automates the process, simplifying the integration of various assets into the Soroban ecosystem.