# The Swirlds SDK demo apps

The Swirlds SDK comes with several demo apps, including source code. They are intended to be simple demonstrations of how the browser works, how consensus works, and how to write apps. One good way to write a new app is to start with the code of a demo app, and modify it. The demo apps are:
Hello Swirld Demo - a very simple app

The app prints a Hello Swirld message to the console along with its name, then creates just one transaction containing that name. Then every member repeatedly prints the list of all transactions received so far, in the current order they are believed to have occurred. They keep printing until as long as the list keeps changing. There are several things visible here. The screen quickly stops changing, which shows consensus was reached quickly. Each member ends up with the names in the same order, which shows the "consensus" was actually a true consensus. If the program is run several times, the final order will be different each time, showing that the exact ordering is dependent on the exact speed with which each member talks to the others, which is nondeterministic. It is also usually the case that at least one member will have several lists where two of the names change order. So it might be that Alice has a row where Bob comes before Carol, and then a later row where Carol comes before Bob. That shows that Alice received both the Bob transaction and the Carol transaction, with her receiving Bob before Carol, but later she realized the community consensus was in the opposite order, so she switched to match the group's consensus.
Game Demo - a simple game

Use the arrow keys (or WASD) to move your character (outlined square) to the goal (outlined circle) to get one point. If you hit the SPACEBAR, your character will move automatically toward the goal, which is the default when it starts. This game is useful for visually seeing timing and lag and consensus. As soon as any player hits the goal, the goal jumps to a new location. The new location of the goal is dependent on which player reached it first. Therefore, you can see history changing, due to the consensus algorithm running, by seeing the location of the goal flicker. It flickers as there are changing opinions on who reached it first. Typically, such flickering is both rare and short-lived, indicating fast consensus. If you take control of a character by using the arrow keys, you can see how responsive its movements are to your actions (local lag), and can see that all the windows show the movement at the same time (global lag). In most cases, the lag is very small.
Hashgraph Demo - display the hashgraph

This allows the user to watch the hashgraph grow, and see how the consensus algorithm works. If the "slow" checkbox is checked, then it intentionally slows down the progress by sleeping frequently, so the image will grow slowly. The other checkboxes can control the display of additional information.
Cryptocurrency Demo - create a cryptocurrency and use it in a simulated stock market

This app creates a cryptocurrency, and uses it in a simulated stock market for 10 stocks. The market and the stocks are simulated. The cryptocurrency is real. At least it would be a real cryptocurrency, if the app were to keep running long enough, and enough people joined it (and if the Swirlds browser has cryptography turned on). In other words, it is a new alt coin that lasts only as long as the program is running.
Stats Demo - gather profiling statistics on how the system runs

This writes to a file various statistics on the system, such as the number of transactions per second. It can run in a windowed mode, where it also shows the statistics on the screen. Or it can run in a headless mode, where there are no windows and it simply creates the file. That can be useful when running on embedded systems that do not support a GUI.
Filesystem Demo - this demonstrates a fast copyable filesystem. This means the app can create what appears to be an external hard drive, and can create files and directories on it. But it is actually shared between all the members, and all of them see a single, consistent view of it as it changes over time. Furthermore, even if it has grown very large, an app can make a "fast copy" of it, which appears to be a new external drive containing an exact copy of all the bytes on the original drive. Both the original and copy can then be modified independently. The "fast copy" happens almost instantly because of a copy-on-write mechanism that causes information to only be truly copied when a file changes.

Back