Learning Ergo 101 : Development Workflow

This post is a continuation of my learning journey of the Ergo blockchain In this post, I assume you are familiar with eUTXO model introduced in a previous post.
This entry covers the workflow for developing a “Smart Contract” on Ergo. Furthermore we touch on the pre-requisites so we can go down the rabbit hole of writing contracts with ErgoScript in another post.
By the end of this entry you should be able to :
- Understand what do you need locally to develop with Ergo
- Understand what is the workflow to take a contract from development to production
- Understand what tooling is available to build your dAPPs
Application Architecture
Developing Apps in the Ergo ecosystem looks like the diagram below.

On the most left you have your App with your business logic. This app uses some of the available ErgoSDKs which provides some code utilities and abstractions to interact with the ErgoBlockchain.
However the SDK inside your app is not enough to communicate with the Ergo blockchain. For your SDK to be able to communicate with the blockchain it has to talk to an Ergo Node.
An Ergo Node provides an API which is used by the SDK logic to carry out operations on the blockchain. Ergo Nodes are the ones who carry out the needed operations on the blockchain.
In summary: you need to talk to an Ergo Node. This is true even in your local development environment. This also applies to your dAPP production environment.
You have two options when it comes to Ergo Nodes: (i) you can run your own Node or (ii) you can use a public one. If you use a public one you should be aware of the security tradeoffs.
Finally, your Ergo Node can talk to either the Ergo TestNet or the MainNet. As the naming convention implies the TestNet is a playground. You can easily make your dApp talk to the TestNet or the MainNet by changing one constant string.
Development Workflow
I think your development workflow really depends on the language you are using. Currently, the Ergo SDK is supported for :
- JVM languages (Scala, Java, Kotlin….) ergo-appkit https://github.com/ergoplatform/ergo-appkit/
- JS (WASM), C, Swift, Rust, Kotlin (JNI)
JVM SDK (ergo-appkit)
If you are using a JVM language such Scala then you are lucky. Because a big chunk of the Ergo development has been done in Scala there is a lot of tooling. The main one is ergo-appkit . This library is the JVM SDK and it provides you all the needed abstractions and functions to play with Ergo.
You also have a powerful tool for testing and simulating your smart contracts: ergo-playgrounds which you can use to mock a blockchain state, run your contract, and then assert the end state of a simulated blockchain.
ergo-playgrounds library
library: https://github.com/ergoplatform/ergo-playgrounds
This library is super powerful as it makes testing a bunch of scenarios a breeze. You see, once you start writing smart contracts you will run into a bunch of “what-if” cases that you REALLY want to test carefully. ergo-playgrounds library makes it super easy simulating possible scenarios .
If you look at the examples in the ergoscript-by-example repository you will see that the examples are coded in this way. The examples in this repository:
1. Prepare a mocked state of the blockchain
2. Run a transaction
3. Assert properties on the final state of the blockchain.
The good news if you are using any JVM lnaguage is that your development process could entirely rely in this tool, this means you can setup your IDE, start coding, and testing without setting up an Ergo Node nor without having to get TestNet tokens etc. The not so good news is as far I know this tool is NOT available in other programming languages.
For my dummy contracts and in my learning journey my local setup in Scala goes like this:
- Setup my sbt project
- Add the ergo-playground library as a dependency
- Add the ergo-appkit library as a dependency
- Code my contract
- Unitest all sort of simulations
Scala project template
For people not familiar with Scala, it can be daunting and overwhelming to setup your own project. the github.com/dav009/ergo-scala-skeleton-app is a cookie-cutter (project template) you can use.
This template project has all the needed dependencies. You can copy that project to bootstrap your app and start coding in your IDE. You can find plenty of Scala tutorials and IDE setups online.
Scastie (online playground)
In case you want to avoid local setups, you can rely on Scastie (an online coding interpreter), this is used in the ergoscript-by-examples. Scastie saves you the hassle of having to install developer tools locally. You can just go to the browser and copy & paste the examples in ergoscript-by-example repo.
Other Languages SDKs
I am not well versed in the other languages SDKs (JS (WASM), C, Swift, Rust, Kotlin (JNI)) . Sadly I don’t have first hand experience. However, I know these SDKs are generated automatically from the ergoplatform/sigma-rust repository. I think there is a lot of efforts into bringing all the goodies of Scala’s ergo-appkit over here.
If you are into Rust or looking to learn Rust there are a lot of mini issues to port features over there. You also get paid for contributions (look at the repo’s bounties).
Your development workflow for these SDKs should involve using the Ergo Node to talk to the TestNet.
Development vs Production Environment
Now you might be thinking but “how do we set up different environments for my App”. My answer is: Don’t worry, just do like you do for any other of your projects: Leave a configuration settings for your app.
When your App starts it will create a different Ergo SDK Client depending on your environment, you just need to pass a different constant.
You need an Ergo node to talk to the TestNet and another one to talk to the MainNet. When you start an Ergo Node you can specify the network type of your node (‘testnet’ or ‘mainet’)
Setting up an Ergo Node
Let’s recap a bit: You want to setup a node so that your SDK can talk the Ergo Blockchain. You can consider two ways to have a local Ergo Node running:
Manual Ergo Node setup
Official tutorial on how to setup an Ergo Node . Be aware that this wiki is a bit outdated so there are a few gotchas.
Docker Ergo setup
You can also use docker to run your own Ergo Node.
- Create a local file with the content below and name it myergo.conf :
ergo {
directory = "/home/ergo/.ergo"
networkType = "testnet"
node {
mining = false
}
}scorex {
restApi {
# Hex-encoded Blake2b256 hash of an API key. Should be 64-chars long Base16 string.
# Below is the hash for "hello" API key (with no quotes)
apiKeyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf"
}
}
2. Create folder under ~/ergo
Run docker by doing
docker run \
-p 9030:9030 \
-p 127.0.0.1:9053:9053 \
-v /path/on/host/to/ergo/data:/home/ergo/.ergo \
-v /path/on/host/system/to/myergo.conf:/etc/myergo.conf \
-e MAX_HEAP=3G \
ergoplatform/ergo --testnet -c /etc/myergo.conf
3. The node will start syncing. It will take some time for the node to sync all needed data (This will likely take a few hours to complete).
4. Once syncing has been done, you can go to http://127.0.0.1:9053/ . We want to use the API to generate a new apiKeyHash (we are using the default “hello” key here just to bootstrap the server).
- Go to http://127.0.0.1:9053/swagger#/utils/hashBlake2b
- Type your secret and hash it
- Keep the hash for the step below
5. Take the key you generated in step 4 and use it as a replacement of the existing apiKeyHash myergo.conf file
6. Restart your server by running killing the previous docker run and running again the same command. You can add the -d
flag to keep running the node in the background.
7. Now you should be ready to use this node from your Ergo SDK clients. We are one step closer from actually coding something.
Notes: Make sure the node is not accessible from outside your local network.
Wrapping things up
- You need to run an Ergo Node as part of your App infrastructure and development environment.
- You can use a node to talk to the TestNet and MainNet.
- There are SDKs in many languages, there are provided via rust bindings.
Further resources
- https://twitter.com/keitodot and https://twitter.com/Haskell_plus are running an ErgoLearn course (First batch in January) follow them for further insights!.
- Ergo testnet faucet ( tokens for testnet ) https://github.com/ergoplatform/ergo/wiki/Ergo-Testnet
- Collection of tutorials running on appkit (Scala) : https://github.com/zackbalbin/ErgoTutorials
- App-kit tutorial with gradle https://github.com/ergoplatform/ergo-appkit/wiki/Tutorial-starting-with-Appkit-on-Gradle-projects
- Scala Appkit Video Tutorial. Most of this post is based on this helpful video: