Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE

Simnet vs. Devnet vs. Testnet vs. Mainnet: What Do They Mean for Web3 Developers?

Simnet vs. devnet vs. testnet vs. mainnet… What are these nets, and why are there so many of them? Mainnet (main network), testnet (test network), devnet (development network), and simnet (simulated network) are terms used to describe different kinds of blockchain networks. Read on to learn more about what each network is for and what role they play in your Web3 development.

Type
Deep dive
Topic(s)
Published
October 11, 2024
Author(s)
Developer Advocate
Contents

Simnet vs. Devnet vs. Testnet vs. Mainnet

Simnet, devnet, testnet, and mainnet refer to types of blockchain networks used for development, testing, or production within a blockchain ecosystem.

  • The first three—simnet, devnet and testnet—are used for deploying code still in development and testing, where developers can learn more about their applications without running the risk of hacks and losing assets with real-world economic value.
  • Mainnet is for production-ready code: users can now interact with your application, trade assets, or leverage whatever service it is that your app offers.

What is a Simnet?

Simnet is a local environment optimized for fast feedback loops and portability. It serves as a means to run the code of your contract in your terminal, and with it, you can create a bunch of reports to analyze your code, such as contract analysis, execution costs, and more.

In Stacks, the main use case of simnet is to run unit-tests on your smart contract with the Clarinet SDK. Simnet is a simulated environment and can be run from anywhere (in the terminal with <code-rich-text>clarinet console<code-rich-text>, web browsers, GitHub actions, etc).

Importance of Simnet to Web3 Developers

Simnet is optimized for providing fast feedback loops at the cost of correctness. Simnet does not provide a full simulated blockchain environment, so there are no concepts of transaction fees, new blocks, or consensus mechanisms.

Instead, simnet focuses on letting you quickly iterate on your code and test the code of the contract locally through unit testing and integration testing. It’s a good preliminary debugging step before introducing the additional variables that come with a fully-fledged blockchain environment.

Simnet is a local environment spun up on your machine and is a private instance—you cannot share a simnet environment with other devs and collaborate with them—and further, simnet has no persistent state. It resets with each run.

Getting Started With Simnet

Clarinet automatically comes with simnet ready to go. If you open Clarinet and interact with your code in the terminal after running the command <code-rich-text>clarinet console<code-rich-text>, that’s simnet. You can call functions in your contract to see if they run correctly, run execution costs, and more. If you need help getting started with simnet, try running the <code-rich-text>::help<code-rich-text> command inside of clarinet console, which will show you all of the keywords you have available to you.

What Is a Devnet?

A devnet (sometimes called a mocknet) is a local blockchain development environment that is used for the rapid development of smart contracts alongside your front-end application development. With a devnet, your smart contract application can interact with simulated blockchain entities (miners, nodes, transaction fees, and a stream of mined blocks), all within your local machine.

Because the development environment mimics a live blockchain network, devnets enable you to create different blockchain configurations to test different scenarios. For example, you can start a devnet at an arbitrary block height with a specified network upgrade at a later block, or you can create a network with a certain number of simulated miners, to see how your app responds.

Importance of Devnet to Web3 Developers 

When devnets simulate a blockchain environment, the entities created—the block streams, API instances, and nodes—resemble the conditions your application will experience in production. But since these are simulations, some of their details or features can be changed to facilitate rapid testing and development. 

For example, on mainnet, Stacks miners mine a block every 10 minutes on average. With devnet, simulated blocks are produced in seconds (and you can adjust that setting to whatever frequency you want), allowing you to rapidly test your code instead of waiting for a 10 minute transaction confirmation.

Devnets are useful for troubleshooting bugs and making sure that the code works as intended with a simulated network before deploying the code on a public network. In particular, devnet is used for end-to-end testing for deployments, multi-contract interactions with wallets and web-based front end applications, and more. You can also run chainhook predicates in devnet.

Unlike testnets, which are public, each devnet is a single local instance of a simulated network. Any developer, or team, that wants to test the code will need to simulate their own devnet in a local environment and do the testing inside it. It is not usually a public environment, though it can be collaboratively shared amongst a team of developers.

To better understand how simnet is different from devnet, and how they shouldn’t be considered mutually exclusive, check out this video:

How To Create a Devnet

Different blockchains have different processes for spawning local devnets. But generally, you can create one through a command line interface tool. For example, to create a devnet for Stacks, you would use Clarinet to spin up devnet locally or interact with devnet in a hosted environment via the Hiro Platform.

What Is a Testnet?

A testnet refers to a public blockchain network used to test smart contracts and apps before they are deployed to mainnet (the live production environment). A testnet is an independent network that runs parallel to mainnet and closely simulates it.

Testnets are designed for stress-testing Web3 apps in a live blockchain environment. These networks are public with real miners and blockchain nodes, and anyone can join and participate. Every mainnet has a corresponding testnet, and some mainnets may even have multiple testnets that offer different configurations for particular use cases.

Importance of Testnet to Web3 Developers 

Testnets are the final step of testing before deploying to the production environment (mainnet). Testnets mimic their corresponding mainnet, with live miners, new blocks being mined, and live transactions, all according to the same protocol rules of mainnet (but occurring independently of that network).

Unlike simnets and devnets (which usually exist only as long as a single session of testing), testnets are persistent. These are public networks that can have a block history that spans years. You will also find activity from other developers and users on testnet: not every transaction will be one you control. This liveness and activity is closer to a production environment.

Importantly, since testnet is a public network, you can not only have your team easily test and debug from the same environment, but you can also recruit beta testers from all over the world to interact with your app, so that you can collect more data and early feedback.

Lastly, it’s worth mentioning that testnets have token faucets, which are digital services that provide you with test tokens. Given that a testnet runs according to the same protocol rules as mainnet, deploying contracts, calling functions, and sending transactions all require spending a native gas token and paying transaction fees. Faucets provide you with these test tokens for free, and since these tokens have no real world value, using testnet is free for everyone.

How To Get Test Tokens for Use on Testnet

Generally, you can find information on how to access the faucet in the documentation of each blockchain ecosystem. You can also reach out directly to the team through community channels such as Discord to find out how to get testnet tokens.

For example, in Stacks, you have 3 ways to get testnet tokens:

Once you access the faucet and request the test tokens, they will be credited to your wallet for use. Some faucets may have limits on the number of test tokens you can get on each attempt, but generally, developers can get as many test tokens from the faucet as they need because the test tokens are free. 

What Is a Mainnet?

A mainnet refers to the live production environment for a particular blockchain. When developers deploy code to a mainnet, that code is now publicly available: users can interact with that code, and other contracts can interact with that code.

Typically, each blockchain has its own mainnet—whether Bitcoin, Ethereum, or Stacks. When you refer to the “Bitcoin network”, you’re talking about mainnet. In Web3 development, launching on mainnet happens at the end of the development cycle, after extensive testing on both devnet and testnet. After deploying code to mainnet, your code is now live on the blockchain—congrats!—and users can interact with your code directly, make deposits, or do whatever it is your code is designed to do.

Importance of Mainnet to Web3 Developers

Mainnet is your production environment where users interact with your smart contract application. This is where the magic happens: users can actually use your app, and you can actually make money.

When deploying on mainnet, take extra care to verify, validate, and test your code first because vulnerabilities on mainnet can be taken advantage of. Hacks, bugs, and exploits on mainnet have consequences. There is no undo button, and your users can lose their crypto assets with no means of recourse.

Significantly and by design, when you publish your smart contract on mainnet, it will reside there forever—part of the censorship-resistance of blockchains—which makes it critically important to do extensive testing before any mainnet deployment. If you deploy a contract with some vulnerability, that vulnerability will be there in posterity, even if you patch it with a new version of your contract.

Simnet vs Devnet vs Testnet vs Mainnet: Which To Use?

Every network serves a purpose, and you will use all of them when creating a Web3 app: simnet for initial debugging and unit testing, devnet for smart contract and front-end interaction testing, testnet for stress testing and beta users, and mainnet for production.

But first you need to write the code, which can be an exciting but potentially intimidating challenge. That’s why we created a comprehensive guide to writing smart contracts, to ease you into the Web3 development journey. Download it for free below:

Product updates & dev resources straight to your inbox
Your Email is in an invalid format
Checkbox is required.
Thanks for
subscribing.
Oops! Something went wrong while submitting the form.
Download Now
Copy link
Mailbox
Hiro news & product updates straight to your inbox
Only relevant communications. We promise we won’t spam.

Related stories