Skip to main content

Overview

Stellar operates two primary testing environments: the Testnet and the Futurenet. These networks allow developers to experiment with Stellar features without risking real assets. Periodically, these networks are reset to ensure they remain clean and manageable.

What is the Testnet and Futurenet reset?

Testnet and Futurenet are reset periodically to the genesis ledger to declutter the network, remove spam, reduce the time needed to catch up on the latest ledger, and help maintain the system. These resets take place approximately quarterly. Resets clear all ledger entries (accounts, trustlines, offers, smart contract data, etc.), transactions, and historical data from Stellar Core, Horizon, and the Stellar RPC, which is why developers should not rely on the persistence of accounts or the state of any balances when using Testnet or Futurenet. You can check current reset dates here.

Why resets are important

  1. Clean Slate: Regular resets ensure that both Testnet and Futurenet provide a clean environment for testing. This helps in avoiding complications arising from old data or configurations.
  2. Performance: Over time, test environments can accumulate a lot of data, which can slow down performance. Resets help in maintaining optimal performance.
  3. Protocol Updates: Introducing new features or protocol changes often requires a reset to ensure compatibility and stability.
  4. Development Cycles: Aligning with development cycles allows developers to plan their testing phases and ensures they have a reliable environment for their work.

Data automation on Testnet and Futurenet

Automating blockchain state on Stellar’s Testnet and Futurenet can streamline development workflows, ensuring that you can consistently test and validate your applications in these environments.

Code walkthrough

Prerequisites:

  • Node.js and npm installed.
  • Stellar SDK for JavaScript and fs installed
  • An understanding of the rudimentary, retry-enabled transaction polling function submitTx which we outlined in another guide

Code

The code defines several asynchronous functions:
  1. createAccount(networkURL):
Generates a new Stellar keypair (public and secret keys). Uses FriendBot to fund the new account on the test network. Returns the created keypair.
  1. issueAsset(issuerKeys, receivingKeys, customAsset):
Sets up a trust line for the receiving account to accept the custom asset, Issues the custom asset from the issuer account to the receiving account.
  1. createLiquidityPool(accountKeypair, nativeAsset, customAsset):
Creates a liquidity pool asset, Sets up a trust line for the pool and Deposits initial liquidity into the pool.
  1. deployAndInvokeContract(deployer, contractWasmFilePath):
Uploads the contract’s WebAssembly (Wasm) code, creates and deploys the contract on the network, invokes the contract function and returns the contract ID and function return values
  1. automateSetup():
Initializes the Stellar server connection, Creates two accounts, Issues a custom asset, Creates a liquidity pool, Deploys a smart contract and returns the contract ID and function values. Helper functions sleep(ms): A utility function to introduce delays in asynchronous operations. submitTx(tx): a retry-enabled transaction submission function submitTx outlined in another guide

Conclusion

Automating the setup of data on the Stellar Testnet and Futurenet can significantly enhance your development workflow, ensuring that you can quickly return to testing after a network reset. By following the above steps and using the provided code samples, you can streamline your processes and maintain consistency across resets.