DEIP Testnet Crash Course

Good news: the DEIP public testnet launch is coming soon (September 6th)! For many of you, it raises a lot of questions: What is testnet? How to participate in testnet? How to use any of its functions?

So, looks like now it is a good time to start building your DEIP blockchain knowledge foundation.

What is testnet?

Testnet is an alternative blockchain that is used for testing. Testnet has some very important properties which differ it from the mainnet:

  • Testnet tokens are separate and distinct from tokens in mainnet. It allows application developers, users, and testers to experiment — without having to use real tokens or worrying about breaking the mainchain.
  • Testnet can be reset. It is possible to reset all the supplied tokens and all the data stored in the testnet blockchain.

How can I participate in the DEIP testnet?

First off, you need to decide on your role in the DEIP blockchain. Here you have a few options: you can be a user; you can run a full node; and finally, you can become a witness and produce blocks.

A user, as its name says, is just any individual who uses the DEIP blockchain as a consumer. It means that a user will not maintain the blockchain in any way.

A testnet member who is running a full node will have a full copy of the database with all the blockchain data including the data required for the website content.

A witness in its turn will be responsible for producing blocks and maintaining the operation of the testnet.

No matter what role you choose, the easiest way to connect to the blockchain is to use official DEIP testnet Docker images. We understand that some of you are not familiar with Docker, images, containers and all that tech stuff. To make your first steps easier, our team has prepared instructions and scripts. However, you still need to go through a few steps and install the required software: Docker and Git.

Install Docker

The first step is to install and setup Docker on your machine. Docker includes documentation which will make the installation process a breeze. Here are the installation instructions for popular operating systems:

Ubuntu
Mac OS
Windows

Install Git

This should be pretty straightforward. Just download an installer for the OS of your choice and follow the instructions.

Once you install Docker and Git, it is time to go further. Let’s make a quick overview of what is inside the DEIP testnet Docker image.

Docker image structure

There are three Docker images for the DEIP testnet: image for a low-memory node, image for a full node, and image for a wallet.

DEIP official testnet node images are based on phusion baseimage-docker, so it is running Ubuntu with some updates and fixes to make services work better inside the Docker container.

The wallet image is based on the lightweight official Ubuntu image.

A low-memory node — a lightweight node which only stores protocol important data and uses a limited set of plugins and APIs. This type of node is suitable for witness nodes and seed nodes.

A full node — a full-memory node which stores all the data (including the data for supporting the website content). Such a node uses most plugins and associated APIs.

The CLI Wallet — a command-line tool to access and use the DEIP blockchain. This tool has most operations available in the DEIP blockchain implemented. However, we recommend to use the Web interface for some operations: due to the nature of certain required data, it may be inconvenient to provide these data using the command-line interface. The wallet application is mostly used for account operations such as account management and balance operations (transfers, vestings), as well as for witness voting.

Starting DEIP Docker container

Now, once you have a basic understanding of what is inside the DEIP testnet image, it is the best time to start it up and see it in action.

There are a few ways to start a container: using a Docker command or using Compose. For this tutorial, we will use Compose. It is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

The DEIP team has prepared docker-compose to make it easier to start the container for people with no prior experience with Docker. All steps below assume you already have Docker installed and running on your machine.

  1. Clone the DEIP testnet GitHub repository to obtain the latest docker-compose.yml file:
    git clone https://github.com/DEIPworld/deip-testnet
    and change the directory to deip-testnet
    cd deip-testnet
  2. Make Compose to pull the latest DEIP testnet image from Docker registry:
    docker-compose pull

Now we have everything set up to start a node or the CLI wallet. There are a few services described in the docker-compose.yml file: node — for a low-memory (witness) node, full_node — for a full node, and wallet — for the wallet. To start a desired service, run the command:

docker-compose run {serviceName}

After you execute the command above, you will see the container name, like deip-testnet_node_run_1.

You can use this name to stop container:

docker stop {containerName}

Node configuration

If you want to run a witness node, you should specify a witness account name and a private key, which will be used to sign blocks. To configure a witness node, set the following parameters in the node-config.env file:

DEIPD_WITNESS_NAME — name of your witness account who will run the node DEIPD_PRIVATE_KEY — your witness account private key

There is also fullnode-config.env with configuration parameters for a full node. Actually, for a full node, no configuration is required, except the case when you want to set seed nodes.

The DEIPD_SEED_NODES parameter presents in both node-config.env and fullnode-config.env configuration files. The DEIP node will use this list of nodes to connect to on startup. We are providing seed nodes, so you should not worry about this option unless you want to run your private testnet with your own nodes addresses.

Running the CLI Wallet

The wallet is a command-line tool which allows you to use the blockchain by accessing the data from open APIs, as well as create, sign and send a transaction to the blockchain.

Starting the wallet is very easy — just run the following command:

docker-compose run wallet -w /var/lib/wallet/wallet.json -s ws://82.196.2.5:8090

After this the wallet will start and will connect to the node at 82.196.2.5 (the full node maintained by DEIP). You can specify a different address if you want to connect to a different node. The wallet file is saved to data folder.

To stop the wallet, press Ctrl + P, Ctrl + Q.

To get a list of all the available arguments, execute:

docker-compose run wallet — help

At first run, the wallet will ask you to set a password to protect your wallet file. You can set a new password with the command:

set_password yourSecretPassword

After you import any keys to your wallet, it will create a wallet file (a file named wallet.json) in the data folder.

Now you are running the wallet — and it is time to create an account.

Creating an account in the DEIP testnet

This step looks familiar — you did it a million times before and you think you can fill in a registration form with your eyes closed. BUT… because of the DEIP free-transactions model, this process is a little bit different from all you have seen before. Especially when you are using the CLI wallet to create an account.

Long story short. You need to use one of the existing accounts to create a new one. It is required because each new account should have some amount of Common tokens in order to be able to send transactions. When an existing account creates a new one, he/she pays an account creation fee, which is credited to the new account balance and converted to Common tokens. It looks like a very wasteful process, but our team has prepared some shared accounts you can use to create the account. Do not worry, they have enough funds to create as much accounts as you want (Yes, we are generous! Testnet tokens have no value anyway).

Now, after we clarified the most confusing thing in the account creation process, you are finally ready to create your own account.

There are two ways to create an account: using the CLI wallet or using our testnet account registration service.

Create an account using the faucet service

For those who want to create an account easily, we created a special service.

The process is very straightforward and simple. All you need is to select the desired username and generate keys. After you finish creating your account, you will be able to use your new account in the CLI wallet to test the DEIP blockchain.

Make sure you saved the keys in a safe place and do not share it with any third parties! It is possible to recover the account, but it is better not to risk losing your account.

Create an account using the wallet

Start the wallet and unlock it using the secret password you set during the previous step (Running the CLI Wallet):

unlock yourSecretPassword

Import a private key of one of the provided shared accounts.

Let’s take ‘alice’ for this example:

import_key 5JGoCjh27sfuCzp7kQme5yMipaQtgdVLPiZPr9zaCwJVrSrbGYx

After you import ‘alice’s’ key, ‘alice’s’ account will be under control of your wallet. It can be controllable by other wallets too.

Now we need to generate keys. To create a new account, you may need up to 4 keys: one key per each role (‘owner’, ‘active’ and ‘posting’) and one ‘memo’ key. You can use the same key for all roles and ‘memo’ — or use different keys for each. In this example, we will use the same key for all roles and ‘memo’. To generate a key, run the suggest_brain_key command. You should see the following response (keys values will be different in each case):

{
 “brain_priv_key”: “CHOLANE MORTIER MIZZLY ELBOW ADAYS SUNKET SUBBASS SHIMMER FLEWS KRAL EXPORT PELTATE UNBUSH CRUCIFY SULK ANNUAL”,
 “wif_priv_key”: “5JEHAET62qWq1Mep3qZhWe2QhTDzF2uzWwgg6DGCify56VBrUkR”,
 “pub_key”: “DEIP6ioSfo5gbaP3YJ3G7ivXATXSLbFLURsB4Y1MmgBFjfepW9qm6u”
}

Make sure you saved the keys in a safe place and do not share it with any third parties! It is possible to recover the account, but it is better to not risk losing your account.

Keys are in place, so now we can create an account. There are a few ways to do it, but we need a method that will create the account with the keys you generated yourself. The name of the method speaks for itself — create_account_with_keys. It takes the following parameters:

  • creator name,
  • new account name,
  • json metadata (can be left empty),
  • owner key,
  • active key,
  • posting key,
  • memo,
  • boolean showing whether you want to broadcast this transaction or not.

Use ‘pub_key’ from the key response we generated previously.

create_account_with_keys “alice” “yourAccountName” “” DEIP6ioSfo5gbaP3YJ3G7ivXATXSLbFLURsB4Y1MmgBFjfepW9qm6u \
DEIP6ioSfo5gbaP3YJ3G7ivXATXSLbFLURsB4Y1MmgBFjfepW9qm6u \ DEIP6ioSfo5gbaP3YJ3G7ivXATXSLbFLURsB4Y1MmgBFjfepW9qm6u \
DEIP6ioSfo5gbaP3YJ3G7ivXATXSLbFLURsB4Y1MmgBFjfepW9qm6u true

Done! After your transaction is validated and included in the block, your new account will be created. To validate that your account was successfully created, run the following command:

get_account “yourAccountName”

Now import your key in the wallet to be able to send transactions using your new account.

Starting from this point, you can use all functions of the DEIP testnet. But there is even more — you can become a witness and produce blocks by yourself. Interested? Check it out below.

Becoming a witness

A witness is a member of the DEIP blockchain responsible for maintaining the blockchain, validating transactions and producing blocks.

To become a witness, execute the update_witness command with the following parameters:

  • account name,
  • your witness url (a web page describing how you will contribute and maintain the operation of the blockchain) — you can leave this field empty for the testnet,
  • your block signing key (public key),
  • your proposed chain properties (account creation fee & maximum block size),
  • boolean showing whether you want to broadcast this transaction or not.

Chain properties object can be left empty (default account creation fee & maximum block size values will be used) or user can define it in the form {“account_creation_fee”:”1.000 TESTS”,”maximum_block_size”:65536}.

update_witness “yourAccountName” “yourAccountUrl” DEIP6ioSfo5gbaP3YJ3G7ivXATXSLbFLURsB4Y1MmgBFjfepW9qm6u {} true

After your transaction is validated and included in the block, your account will become a witness. It does not mean you will start producing blocks right away though. To become an active witness, you need to be included in the witness schedule. To make sure you are included in the schedule, you need to get some votes for your witness. You can vote for yourself or use any of shared accounts to vote:

vote_for_witness “alice” “yourAccountName” true true

To verify that your account received votes, run the get_witness command:

get_witness “yourAccountName”

When your witness gets enough votes, you can start a witness node by providing the DEIPD_WITNESS_NAME and DEIPD_PRIVATE_KEY parameters in node-config.env.

Hooray! You are producing blocks now and will be rewarded with some tokens for your work.

Conclusion

It was a long way — from starting a node to producing blocks and using the CLI wallet like you have been doing it your whole life. Now it is time to explore all the possibilities the DEIP blockchain gives you. And do not worry if one day everything is reset — then it will be a great chance to go through all those steps again (practice makes perfection). Remember: it is a TESTnet after all, so there may be a lot of surprises and we would like to know about them if you find any!

Alexey Kulik, Chief Blockchain Officer, DEIP