Spinning Up Your First Testnet

Start Core By Running Testnet On Your Local Computer

To learn about possible Core running modes follow this page:

Step 1: Start Docker Testnet Database

You already generated docker files during the development environment setup (if not please run the following commands as specified here).

cd core/docker/development/testnet #testnet docker folder
docker-compose up postgres #start postgres testnet container

Step 2: Testnet Network Boot

Let's jump to the core/packages/core and start our first testnet with the commands below:

Please make sure you have already run the build command yarn setup from core root folder.

cd core/packages/core
yarn full:testnet #run the testnet blockchain on your local computer

After executing the yarn full:testnet command you should see something like this in your command prompt:

yarn run v1.17.3
$ cross-env CORE_PATH_CONFIG=./bin/config/testnet yarn ark core:run --networkStart --env=test
$ ./bin/run core:run --networkStart --env=test
[2019-10-02 10:53:08.534] DEBUG: ark-core 2.5.0-next.10
[2019-10-02 10:53:08.546] DEBUG: Data Directory: /Users/ark/Library/Application Support/ark-core/testnet
[2019-10-02 10:53:08.546] DEBUG: Config Directory: ./bin/config/testnet
[2019-10-02 10:53:08.547] DEBUG: Cache Directory: /Users/ark/Library/Caches/ark-core/testnet
[2019-10-02 10:53:08.547] DEBUG: Log Directory: /Users/ark/Library/Logs/ark-core/testnet
[2019-10-02 10:53:08.548] DEBUG: Temp Directory: /var/folders/t1/44pfsqf54tg2xnl6rwn8bp7h0000gn/T/ark-core/testnet
[2019-10-02 10:53:08.934] INFO : Starting Database Manager
...

This means that you core node is now running and simulating a blockchain on your local computer.

Step 3: Your First API Call

With our testnet up and running, the first thing we need to do is connect to it. All interactions between ARK Nodes and the outside world happen through the Public API, which is a REST API facilitating different actions on the blockchain.

It is possible to interact with a node directly through HTTP without using any programming language at all. By default, the Public API for testnet opens a connection on your local machine at http://0.0.0.0:4003/api. We can check out newly forged blocks in our browser with a running testnet. You should see a response showing you all the (empty) blocks your testnet forgers have recently created.

Let's try to retrieve the latest block and supply by calling the GET api/blockchainendpoint with curl. Run the following request from console via curl command or via browser.

Request:

curlhttp://127.0.0.1:4003/api/blockchain

We should get the following response:

{
"data": {
"block": {
"height": 145,
"id": "17498538834395765847"
},
"supply": "12500000000000000"
}
}

Your core server is now running and responding to your requests. Look at the Public REST API and play with some requests so you get a better feel for how things run. Try some of the following endpoints:

In the next phase we will build a simple transaction using the core-tester-cli package and post it to the local network.