# What is Axentro?

Axentro is an original proof of work blockchain platform that empowers developers to build decentralised apps quickly and cheaply. It features the following:

* CPU only mining using the award winning Argon2d hashing algorithm
* Decentralized apps platform
* Human readable addresses
* Smart assets
* Distributed two factor authentication
* Globally shared distributed mining rewards

## Whitepaper

You can read our [WhitePaper](https://axentro.io/axentro_whitepaper.pdf)

## Why is it named Axentro?

* Developed from the word 'accent' which means to 'heighten' or 'peak' Axentro is an blockchain that is aiming for the top in terms of simplicity, usability and relevant features.

## Specification

|                 Name | Axentro                   |
| -------------------: | ------------------------- |
|          Coin ticker | AXNT                      |
|            Coin name | AXNT                      |
|            Consensus | CDPoW                     |
|     Max Block reward | 12 AXNT (decreasing)      |
|         Miner reward | Prorated on contribution  |
|   Slow Block spacing | 120 seconds               |
|   Fast Block spacing | 2 seconds                 |
|   Block spacing algo | Dark Crystal Gravity Wave |
|       Developer fund | 10,000,000 AXNT           |
|       Total mineable | 20,000,000 AXNT           |
|   Total non-mineable | 15,000,000 AXNT           |
|         Total Supply | 45,000,000 AXNT           |
|             Maturity | 7 Blocks                  |
|      Minimum txn fee | 0.0001 AXNT               |
| PoW mining algorithm | Argon2id                  |
|                 Port | 80/443                    |


# Environments & Tools

## Environments

The Axentro platform has 2 environments:

* TestNet (for testing and pre-releases) - <http://testnet.axentro.io>
* MainNet (for real) - <http://mainnet.axentro.io>

## Desktop Wallet

We have a cross platform Desktop wallet which you can download and install from our website

* Desktop Wallet - see [Installing the desktop wallet](/getting-started/install-desktop-wallet)

## Web Wallet

We have a web wallet. Please BACKUP the wallet via the tools menu as it's stored encrypted in local browser storage

* Web Wallet - <https://axentro.xyz/>

## Blockchain Explorer

We also have a Blockchain Explorer:

* TestNet - <https://testnet-explorer.io> (not up at the moment)
* MainNet - <https://explorer.axentro.io>

## Mining Tools

We have 2 mining tools:

* `MinAxnt` (Recommended) - cross platform mining - see [How to mine](/using-the-cli/how-to-mine)
* `Axem` - Linux, MacOs - see [How to mine](/using-the-cli/how-to-mine)

## Node & Client

We have the node itself and the node client

* `Axen` is the node server - more documentation is coming about this
* `Axe` is the node client - see [Using the Cli](/using-the-cli/install)


# Install Desktop Wallet

Axentro has a cross platform Desktop wallet which can be installed from the [Axentro website](https://axentro.io). It has been tested on Windows, Linux and MacOS and is fully codesigned and safe.

The best way to learn how to install the wallet is by watching the following installation video (click the image):

[![wallet-install](http://img.youtube.com/vi/_jpBfK93emM/0.jpg)](http://www.youtube.com/watch?v=_jpBfK93emM)


# Wallet Creation

Use the Desktop wallet to create your wallets following this video guide (click the image):

[![wallet-creation](http://img.youtube.com/vi/aZd9ZPfDC2g/0.jpg)](http://www.youtube.com/watch?v=aZd9ZPfDC2g)


# Backing Up Your Wallet

You should always back up your wallet and this video explains exactly how to do that (click the image):

[![wallet-backup](http://img.youtube.com/vi/M8goK0jfaBA/0.jpg)](http://www.youtube.com/watch?v=M8goK0jfaBA)


# Sending And Receiving

It's easy to send and receive tokens using the Axentro Desktop Wallet by following this video guide (click the image):

[![wallet-send-receive](http://img.youtube.com/vi/ccPgG_OLJdk/0.jpg)](http://www.youtube.com/watch?v=ccPgG_OLJdk)


# Create Human Readable Address

You can learn how to create human readable addresses via this video guide (click the image):

[![wallet-human-readable-address](http://img.youtube.com/vi/y62BuWyUbJ4/0.jpg)](http://www.youtube.com/watch?v=y62BuWyUbJ4)


# Creating Tokens

Creating and working with user defined tokens is easy when following this video instruction guide (click the image):

[![wallet-create-tokens](http://img.youtube.com/vi/3xdCZcD9Cyw/0.jpg)](http://www.youtube.com/watch?v=3xdCZcD9Cyw)


# How To Mine

There are 2 ways to mine currently.

* `MinAxnt` - cross platform miner (Recommended)
* `Axem` - runs on Linux, MacOs and currently must be compiled from the Axentro source code

You can mine against the testnet (for experimenting) or mainnet (for real):

* <http://testnet.axentro.io>
* <http://mainnet.axentro.io>

## Using MinAxnt

You can mine using MinAxnt on Windows, Linux, MacOs and Android mobile phones. This is the easiest way to get started and the one we recommend.

* [General Instructions](https://github.com/Axentro/minaxnt)
* [Mining on Android phones](https://github.com/Axentro/minaxnt/wiki/Install-MinAXNT-on-Android-device)

## Using Axem

To use the `axem` binary you must first compile and build it. See instructions for [installing the cli tools](/using-the-cli/install). The `axem` tool only runs on Linux and MacOs.

```bash
> ./axem -w testnet-wallet-1.json --testnet -n http://testnet.axentro.io --process=2
```

This is going to startup a miner that connects to the testnet node with 2 processes. We supply the wallet we want our rewards to go to with the `-w` flag. The `-n` flag is how we specify our connecting node - which in this case is the testnet node.

Leave the miner running for about 2-3 minutes and then let's have a look in our wallet. You can either look in the desktop wallet or use the `axe` cli if you installed it ([installing the cli tools](/using-the-cli/install))

You can also look in the blockchain explorer:

* MainNet - <https://explorer.axentro.io/>
* TestNet - <https://testnet-explorer.axentro.io/>

```bash
> ./axe wallet amount -w testnet-wallet-1.json -n http://testnet.axentro.io
```

If we look at the amount of `AXNT` tokens you will see you will have something like 0.7

Depending on when you look - you might see it still says 0.0 - but after mining for a while the transactions will be processed and the blocks added to the testnet and then you will see the balance start to increase. Mining blocks are mined approximately every 2 minutes.

## Mining against other nodes

You can mine against any node simply by passing in the node's url with the `-n` flag. For example you could startup a public node that is connected to the public testnet and mine against the testnet via your public node. In essence this is how mining pools work on Axentro.

More information will be provided on running public nodes in the near future

## Rewards

The main motivation for mining is to receive rewards. When a new block is mined the maximum total payout is `12 AXNT` but this value decreases over time with each block that is mined. The node on which the block was mined always receives `25%` of the total payout and all the miners connected to the node receive a prorated amount depending on how many hashes each miner has worked through.

For example a single miner on the network would expect to receive the full `75%` of the block reward. Three miners all working at approximately the same hash rate would receive `25%` each. In some cases if there are a great many miners connected to the node and some of them have an insignificant hash rate compared to the majority then they will not receive any reward.


# Installation

Follow the directions below to install Axentro from source:

1. install the [Crystal programming language](https://crystal-lang.org/reference/installation/)
2. Clone the [Axentro](https://github.com/Axentro/Axentro) repository from Github

   `git clone https://github.com/Axentro/Axentro.git`
3. Install dependencies

   `shards install`
4. Build the binaries:

   `shards build --release --no-debug`
5. Install the binaries on your path (might need to use sudo):

   ```
   mkdir -p /usr/local/bin/axentro

   cp bin/axe /usr/local/bin/axentro

   cp bin/axen /usr/local/bin/axentro

   cp bin/axem /usr/local/bin/axentro
   ```
6. You invoke the CLI binaries in your terminal by typing:

   `axe` - The command line blockchain client

   `axem` - The command line miner

   `axen` - The blockchain node


# Creating A Wallet

Let's create our first wallet on the testnet.

```bash
> ./axe wallet create -w testnet-wallet-1.json --testnet
```

The `-w` flag is used to specify the file location of the new wallet you want to create. In this instance it's going to be created in the local directory you are running the command from - but you can specify any location to generate it into to.

The `--testnet` flag is used to indicate that we want to create this wallet for use on the testnet. If we left this off - our wallet would be created using the default which is for mainnet.

We can also create an encrypted wallet - see the [encrypt/decrypt the wallet](/using-the-cli/creating-a-wallet#encrypt-decrypt-a-wallet) section for more details.

So now we have a wallet we can do a few things with it:

* [verify it's a valid wallet](/using-the-cli/creating-a-wallet#verify-the-wallet)
* [check the amount of coins we have in the wallet](/using-the-cli/creating-a-wallet#check-the-balance)
* [encrypt/decrypt the wallet](/using-the-cli/creating-a-wallet#encrypt-decrypt-a-wallet)

## Verify the wallet

```bash
> ./axe wallet verify -w testnet-wallet-1.json
```

and we should see

```bash
testnet-wallet-1.json is perfect!
address: VDBkMzRmOWZlYWEwYmM4OWY4MjZhNDlmZThhNTY1MmI3NzZjYTNkZjVlNzYzMjZi
network (T0): testnet
```

## Check the balance

```bash
> ./axe wallet amount -w testnet-wallet-1.json -n http://testnet.axentro.io
```

Here we are checking the balance against the testnet - but you can supply the url of any node or even a locally running private node.

When you check the balance it shows the amount of confirmations. This is the number of blocks ontop of the block that contains the latest transaction that affects your wallet balance. In an active wallet e.g. used in mining - it will most likely always be 0 as new transactions are constantly arriving. But for less active wallets the number will vary depending on when the last transaction was.

```bash
> ./axe wallet amount -w testnet-wallet-1.json -n http://testnet.axentro.io
```

## Encrypt / Decrypt a wallet

We can also choose to encrypt an existing wallet, or decrypt and existing encrypted wallet. Also if we just want to always use an encrypted wallet we can create an encrypted wallet by adding the `-e` flag when creating the wallet.

All of the commands that require a wallet can also accept an encrypted wallet - you just have to either give the command the `--password=` flag or set the environment variable: `WALLET_PASSWORD`

### Create an encrypted wallet

```bash
> ./axe wallet create -w my-wallet.json -e --password=my-very-secure-password --testnet
```

### Encrypt a wallet

```bash
> ./axe wallet encrypt -w my-clear-text-wallet.json --password=my-very-secure-password
```

This creates an encrypted version of the wallet prefixed with `encrypted` along side the original

### Decrypt a wallet

```bash
> ./axe wallet decrypt -w my-encrypted-wallet.json --password=my-very-secure-password
```

This creates an unencrypted version of the wallet prefixed with `unencrypted` along side the original


# Mining

There are 2 ways to mine currently.

* `MinAxnt` - cross platform miner (Recommended)
* `Axem` - runs on Linux, MacOs and currently must be compiled from the Axentro source code

You can mine against the testnet (for experimenting) or mainnet (for real):

* <http://testnet.axentro.io>
* <http://mainnet.axentro.io>

## Using MinAxnt

You can mine using MinAxnt on Windows, Linux, MacOs and Android mobile phones. This is the easiest way to get started and the one we recommend.

* [General Instructions](https://github.com/Axentro/minaxnt)
* [Mining on Android phones](https://github.com/Axentro/minaxnt/wiki/Install-MinAXNT-on-Android-device)

## Using Axem

To use the `axem` binary you must first compile and build it. See instructions for [installing the cli tools](/using-the-cli/install). The `axem` tool only runs on Linux and MacOs.

```bash
> ./axem -w testnet-wallet-1.json --testnet -n http://testnet.axentro.io --process=2
```

This is going to startup a miner that connects to the testnet node with 2 processes. We supply the wallet we want our rewards to go to with the `-w` flag. The `-n` flag is how we specify our connecting node - which in this case is the testnet node.

Leave the miner running for about 2-3 minutes and then let's have a look in our wallet. You can either look in the desktop wallet or use the `axe` cli if you installed it ([installing the cli tools](/using-the-cli/install))

You can also look in the blockchain explorer:

* MainNet - <https://explorer.axentro.io/>
* TestNet - <https://testnet-explorer.axentro.io/>

```bash
> ./axe wallet amount -w testnet-wallet-1.json -n http://testnet.axentro.io
```

If we look at the amount of `AXNT` tokens you will see you will have something like 0.7

Depending on when you look - you might see it still says 0.0 - but after mining for a while the transactions will be processed and the blocks added to the testnet and then you will see the balance start to increase. Mining blocks are mined approximately every 2 minutes.

## Mining against other nodes

You can mine against any node simply by passing in the node's url with the `-n` flag. For example you could startup a public node that is connected to the public testnet and mine against the testnet via your public node. In essence this is how mining pools work on Axentro.

More information will be provided on running public nodes in the near future

## Rewards

The main motivation for mining is to receive rewards. When a new block is mined the maximum total payout is `12 AXNT` but this value decreases over time with each block that is mined. The node on which the block was mined always receives `25%` of the total payout and all the miners connected to the node receive a prorated amount depending on how many hashes each miner has worked through.

For example a single miner on the network would expect to receive the full `75%` of the block reward. Three miners all working at approximately the same hash rate would receive `25%` each. In some cases if there are a great many miners connected to the node and some of them have an insignificant hash rate compared to the majority then they will not receive any reward.


# Sending Coins

Ok so now we have some coins - what can we do with them? Well we could send them to someone else!

create a second wallet:

```bash
> ./axe wallet create -w testnet-wallet-2.json --testnet
> cat testnet-wallet-2.json
```

the `cat` command will show you the contents of the wallet including the address field. copy and paste the address field so you can use it to send coins to.

```bash
> ./axe transaction create -f 0.0001 -m 2 -a VDA3NmZkZmQ5MTQyNjgwZGQ4ZDYzYjA1MjA4NjAxYjg1OWVlMWYyMmJkNTcxMWQ2 -w testnet-wallet-1.json -n http://testnet.axentro.io
```

* The `-f` flag is the fee - every transaction has a fee - sending coins has a minimum fee of 0.0001 AXNT.
* The `-m` flag is the amount of coins to send - here we said 2 coins.
* The `-a` flag is the address we want to send to (the address from our second wallet we created above)

Now when you check the first wallet's amount you will see it is 2 coins (plus the fee) less than it was before. Everytime you send some coins the sender gets charged a small fee.

Have a look at the coins for wallet1:

```bash
> ./axe wallet amount -w testnet-wallet-1.json -n http://testnet.axentro.io
```

Now have a look at the coins for wallet2:

```bash
> ./axe wallet amount -w testnet-wallet-2.json -n http://testnet.axentro.io
```

You will see wallet2 now has 2 coins in it.

We can see the fees here:

```bash
> ./axe transaction fees
```

Currently it costs 0.0001 coin per `send` transaction


# Human Readable Addresses

HRA or Human Readable Addresses are a built in service that allows you to choose a human readable name that maps to your wallet address.

So instead of long and hard to remember address string that looks like this:

```
VDAxNmM1OGVkNmYyNzI2NzcyYjYzODRmMzJmMDkzODhjMTczNWI0NDFjZGM5ZTIz
```

You can have a nice easy to remember name of your choice - something like this:

```
pacman.ax
```

In HRA the name is called a domain and you can map as many as you like to an address. When choosing a name you just have to follow these simple rules:

1. The name must be alphanumeric (numbers and letters only)
2. The minimum length is 1 and the maximum length is 20
3. It must end in `.ax`

Obviously if the name is already taken you won't be able to register it. Registering names is free but as it's a transaction there is still a fee (currently 0.001 AXNT)

You can choose to sell a domain or buy one from the list of domains up for sale. You can cancel a sell order if nobody has bought it yet.


# Registering a domain

Since registering a domain is free you can easily do this from the `axe` command line client. Lets see an example:

* First create a wallet (if you already have one you can skip this step) on the testnet

```bash
> ./axe wallet create -w testnet-wallet-1.json --testnet
```

* Let's check the fees so we know the amount we need to specify

```
> ./axe transaction fees -n http://testnet.axentro.io

  + ------------------------------ - ------------------------------ +
  |                         action |                            fee |
  | ------------------------------ | ------------------------------ |
  |                           send |                         0.0001 |
  |                        hra_buy |                          0.001 |
  |                       hra_sell |                         0.0001 |
  |                     hra_cancel |                         0.0001 |
  |                   create_token |                             10 |
  + ------------------------------ - ------------------------------ +
```

As you can see the fee for buying a domain is `0.001` so with a new wallet we will need to do a bit of mining to generate some coins we can use. So let's fire up a miner against the testnet:

```bash
> ./axem -w testnet-wallet-1.json --testnet -n http://testnet.axentro.io --process=2
```

Keep checking your wallet and when you have some coins in your wallet then you are ready to keep going (it could take about 10-15 mins):

```bash
> ./axe wallet amount -w testnet-wallet-1.json -n http://testnet.axentro.io
```

* Now lets create a domain for the wallet (the fee is 0.001) - and just set the price to 0

```bash
> ./axe hra buy -w testnet-wallet-1.json -n http://testnet.axentro.io -f 0.001 --price=0 --domain=mydomain.ax
```

If it was successful you will get a success message that includes a transaction id - once this transaction is processed the domain will be available. So we can check the transaction id to see if it's been processed:

```bash
> ./axe transaction transaction -n http://testnet.axentro.io -t dd49e07900bf0187c97acce175422231f2983f0b5b8f6a7cd6aaf885c4728d76
```

after a while the transaction will be processed and you will see a result saying the transaction was found.

Once it reports that the transaction has been processed we can check the domain can be resolved and if all is good we can start using it:

```bash
> ./axe hra resolve -n http://testnet.axentro.io --domain=mydomain.ax

show information of domain fullmetal.ax
resolved : true
address  : VDA4NTAxMzI1NmExZmY0ZTVkMGRjMGU4MGE0MWZlZThmYjNlZGYwYTAzMjYzYTI4
status   : acquired
price    : 0
```


# Using the domain

So now you have a domain - you can do a few things:

* receive coins/token to the domain
* query the wallet amounts via the domain
* sell the domain for profit

Let's try to receive some coins to our wallet via the domain

## Sending coins to the domain

You will need another wallet to be able to send coins to your wallet with the domain. If you don't have another one - go and follow the instructions to [create and populate a wallet](/using-the-cli/creating-a-wallet) with some coins and [sending coins](/using-the-cli/sending-coins).

So firstly lets see how many unconfirmed coins our wallet with the domain has:

```
> ./axe wallet amount --domain=mydomain.ax -n http://testnet.axentro.io

 showing amount of each token for VDA4NTAxMzI1NmExZmY0ZTVkMGRjMGU4MGE0MWZlZThmYjNlZGYwYTAzMjYzYTI4.
 confirmation: 1

  + -------------------- - -------------------- +
  |                token |               amount |
  | -------------------- | -------------------- |
  |                 AXNT |          59.29161346 |
  + -------------------- - -------------------- +
```

and now lets send some coins to the wallet with the domain:

```bash
./axe transaction create -w testnet-wallet-2.json -n http://testnet.axentro.io -m 2 -f 1 --domain=fullmetal.ax
```

So now once the transaction has been processed we should see the amount of coins in `mydomain.ax` increase by 2.

```
> ./axe wallet amount --domain=mydomain.ax -n http://testnet.axentro.io

 showing amount of each token for VDA4NTAxMzI1NmExZmY0ZTVkMGRjMGU4MGE0MWZlZThmYjNlZGYwYTAzMjYzYTI4.

  + -------------------- - -------------------- +
  |                token |               amount |
  | -------------------- | -------------------- |
  |                 AXNT |          61.29161346 |
  + -------------------- - -------------------- +
```


# Buying & selling domains

In the previous part of this guide we saw how to buy a domain (for a price of 0) from the platform. But we can also buy from someone who has put their domain up for sale.

To see what is up for sale:

```
> ./axe hra sales -n http://testnet.axentro.io

hra domains for sale!

 Domain     | Address        | Price
 awesome.ax | VDAxNmM1OGV... | 5
```

Buying a domain is exactly the same as in the first part of this guide except you must specify the price correctly:

```bash
> ./axe hra buy -w testnet-wallet-1.json -n http://testnet.axentro.io -f 0.001 --price=5 --domain=awesome.ax
```

Follow the same procedure of checking the transaction.

Selling a domain is also easy:

```bash
> ./axe hra sell -w testnet-wallet-1.json -n http://testnet.axentro.io -f 0.0001 --price=8 --domain=mydomain.ax
```

and if you change your mind before someone else buys it you can cancel the sell:

```bash
> /axe hra cancel -w testnet-wallet-1.json -n http://testnet.axentro.io -f 0.0001 --domain=mydomain.ax
```

Remember to pay the correct fees when doing all these transactions.


# What is CLI config?

## What is config for

Config can be used with all the binaries and provides a shortcut when using the command line. Consider this example:

```bash
> axe tx create -m 5 -f 0.0001 -w wallets/w1.json -n http://testnet.axentro.io -a some-address --testnet --password=password
```

For every command you have to specify several command line options. Config can save these so you don't have to pass them everytime and instead if not passed they are retrieved from the config store. If any of the options are provided on the command line then they override any previously stored config options.

This provides a very easy to use and flexible configuration solution. The above command could be shortened using config to this:

```bash
> axe tx create -m 5 -f 0.0001 -a some-address
```

we think you will agree that is much easier to work with.

## Usage

There are 7 things you can do with config:

```
available sub actions
 - save                 | save the specified options as default for axe, axen and axem
 - show                 | show current default configuration
 - remove               | remove the default configuration
 - use                  | use the specified configuration
 - list                 | list the available configurations
 - enable               | enable configurations
 - disable              | disable configurations
```

In addition to those usages you can also override config completely - which is very hand if you have saved config for different things e.g

```bash
> axen --config=myserver1
> axem -c myminer1
> axe wallet amount -c wallet1
```

### Save

Save stores the specified config to the location: `~/.axentro/config`. You just have to supply the config you would like to save and a config name to save it under (the default name is config which is used if no name is supplied):

```bash
> axe config save -n http://testnet.axentro.io --testnet --config=myconfig
```

### Show

You can view the list of stored config using the show command:

```bash
> axe config show
```

```
current configuration is for: 's1t' in file /Users/kings/.axentro/config
configuration is Enabled
--------------------
connect_node:    http://testnet.axentro.io
wallet_path:    /Users/kings/sc-wallets/w1.json
is_testnet:    true
is_private:    true
bind_host:    0.0.0.0
bind_port:    3000
processes:    1
encrypted:    false
```

### Remove

If you want to remove a specific configuration or all configurations (this will delete the config file)

```bash
> axe config remove --config=myconfig
> axe config remove
```

### Use

If you want to switch to using a different default config:

```bash
> axe config use --config=myconfig
```

### List

To see a list of all the saved configs

```bash
> axe config list
```

### Enable / Disable

If you want to completely disable configurations so they don't apply or turn them back on again:

```
> axe config disable
> axe config enable
```

## Supported config

The following config can be saved:

| Option name     | Flag        | binary |
| --------------- | ----------- | ------ |
| Connecting node | -n          | all    |
| Wallet path     | -w          | all    |
| Wallet password | --password= | all    |
| Is testnet      | --testnet   | all    |
| Is private      | --private   | axen   |
| Bind host       | -h          | axen   |
| Bind port       | -p          | axen   |
| Public url      | -u          | axen   |
| Database path   | -d          | axen   |
| Threads         | --threads=  | axem   |
| Encrypted       | -e          | axe    |


# Overview

You can read the full API documentation here:

* [TestNet API Documentation](https://testnet.axentro.io)
* [MainNet API Documentation](https://mainnet.axentro.io)

The API has many endpoints for retreiving various information about the blockchain but the most common questions are listed below with which API's to use: (links are for the mainnet version)

Most of the API's are paginated when returning lots of data.

## Get the balance of an address

The wallet adddress API endpoint returns the wallet balances along with the most 50 recent transactions.

* [api/v1/wallet/{**address**}](https://mainnet.axentro.io/#/get~wallet~address)

The token amount API endpoint returns the balance for a specified token in the specified wallet

* [api/v1/address/{**address**}/token/{**token**}](https://mainnet.axentro.io/#/get~address~address~token~token)

## Getting a specific transaction detail

Transaction detail for a specific transaction can be found using the transaction API

* [api/v1/transaction/{**transaction\_id**}](https://mainnet.axentro.io/#/get~transaction~id)

## Getting a list of transactions

You can also find a list of transactions for the following:

* All transactions [api/v1/transactions](https://mainnet.axentro.io/#/get~transactions)
* Transactions for a block [/api/v1/block/{**index**}/transactions](https://mainnet.axentro.io/#/get~block~index~transactions)
* Transactions for an address [/api/v1/address/{**address**}/transactions](https://mainnet.axentro.io/#/get~address~address~transactions)
* Transactions for a domain [/api/v1/domain/{**domain**}/transactions](https://mainnet.axentro.io/#/get~domain~domain~transactions)

## Confirmations & Transaction Speed

Most of the API responses for blocks and transactions also return the number of confirmations. This is the number of blocks that are ontop of the block that contains your transaction. The number of confirmation required to be confident in the chain depends on whether the transaction was send via FAST transaction or SLOW transaction.

SLOW transactions are included in the block that the miners mine and will take approximately 2 minutes to be mined. FAST transactions are send instantly as a new FAST block is minted every 2 seconds on demand. Therefore for FAST transactions confirmations are not applicable because FAST transactions are written into FAST blocks which are guaranteed to be written into the chain.

When sending transactions it's recommended to use FAST transactions.

* Confirmations for SLOW transacations: 7&#x20;
* Confirmations for FAST transactions: 0

## Signing and Sending Transactions

Please see the [Signing and Sending Transactions](/using-the-api/signing-and-sending-transactions) page for detailed information.


# Signing & Sending Transactions

In order to send tokens from your address to another address using the API there are a few steps described below:

* generate an unsigned transaction json
* sign the generated unsigned transaction json
* post the json to the transaction endpoint

## Generating an unsigned transaction json

The first step is to use the API endpoint: <https://mainnet.axentro.io/api/v1/transaction/send_token/unsigned> by making a POST request with the json for the transaction:

```javascript
{
 "from_address": "VDBkYWQxZjZlZjllOTAzYzNiODQ0NmZkZTI4NDBhYmMzYjUxYThjM2E1ZjNkODlj",
 "public_key": "48c45b7e45cd415187216452fa22523e002ca042c2bd7205484f29201c3d5806f90e7aeebad37e3fbe01286c25d4027d3f3fec7b5647eff33c07ebd287b57242",
 "amount": "10",
 "fee": "0.0001", 
 "to_address": "VDBlY2I4ZjA5MTUxOWE0MTIwNTRmZjlhYTM1YjYxMjcwNjM1YzcxYjlkMDZhZDUx", 
 "kind": "FAST"
}
```

You can get this information from your wallet. If you use the desktop wallet you can go to tools backup and it will produce a backup json that has this information. If you created your wallet using the cli tool `axe` then it produces the same json as the desktop wallet.

for example given this wallet json:

```javascript
{
 "public_key":"8b3c61787fb6b07bb20e4a908deca52ef96335e4faaaaca18a227f9d674dcc57",
 "wif":"VDBhMjY5YzE4NzA1YmY4MTRiMmE2Y2I2NGY1NjllMjdmMzAzMDIwMmMwZTZkNDczNjBlM2M5OGNkZWMzNmUwODY1OTNkMjdi",
 "address":"VDAyNThiOWFiN2Q5YWM3ZjUyYTNhYzQwZTY1NDBmYWJkMjczZmVmZThlOTgzMWM4"
}
```

You can see the `address` and `public_key` needed for the POST request mentioned above.

* It is recommened to use FAST for the kind - this is the transaction kind and fast transactions are instant
* the fee for sending a transaction is 0.0001 - The API has an endpoint that lists the fees

So now you can make a POST request to the endpoint `https://mainnet.axentro.io/api/v1/transaction/send_token/unsigned` with the json mentioned above as the payload.

The request will return a response with a transaction json that you can sign and POST to make the actual transaction.

## Signing the generated transaction json

The json returned from the `api/v1/transaction/send_token/unsigned` endpoint should look similar to this:

```javascript
{
  "status": "success",
  "result": 
    {
      "id": "8069e6049f7175229f8e05e5cf4cd5dacbc82cad08bfbd251408b6e980d90b04",
      "action": "send",
      "senders": 
        [
          {
            "address": "VDBkYWQxZjZlZjllOTAzYzNiODQ0NmZkZTI4NDBhYmMzYjUxYThjM2E1ZjNkODlj",
            "public_key": "48c45b7e45cd415187216452fa22523e002ca042c2bd7205484f29201c3d5806f90e7aeebad37e3fbe01286c25d4027d3f3fec7b5647eff33c07ebd287b57242",
            "amount": 500000000000,
            "fee": 100000000,
            "signature": "0"
          }
        ],
      "recipients": 
        [
          {
            "address": "VDBlY2I4ZjA5MTUxOWE0MTIwNTRmZjlhYTM1YjYxMjcwNjM1YzcxYjlkMDZhZDUx",
            "amount": 500000000000
          }
        ],
      "message": "",
      "token": "AXNT",
      "prev_hash": "0",
      "timestamp": 1529781499,
      "scaled": 1,
      "kind": "FAST",
      "version": "V1"
    }
}
```

You need to first remove all the line breaks and all the spaces between the json properties so that it looks like this:

```javascript
{"id":"8069e6049f7175229f8e05e5cf4cd5dacbc82cad08bfbd251408b6e980d90b04","action":"send","senders":[{"address":"VDBkYWQxZjZlZjllOTAzYzNiODQ0NmZkZTI4NDBhYmMzYjUxYThjM2E1ZjNkODlj","public_key":"48c45b7e45cd415187216452fa22523e002ca042c2bd7205484f29201c3d5806f90e7aeebad37e3fbe01286c25d4027d3f3fec7b5647eff33c07ebd287b57242","amount":500000000000,"fee":100000000,"signature":"0"}],"recipients":[{"address":"VDBlY2I4ZjA5MTUxOWE0MTIwNTRmZjlhYTM1YjYxMjcwNjM1YzcxYjlkMDZhZDUx","amount":500000000000}],"message":"","token":"AXNT","prev_hash":"0","timestamp":1529781499,"scaled":1,"kind":"FAST","version":"V1"}
```

Remove the surounding json for status and result and just take the payload in the result so you have just the payload of the json with all spaces and new lines removed. If you get this wrong the hash will not match and the transaction will be rejected with invalid signing.

Next you need turn the json above into a `SHA256` hash and then sign it with your private key that you must convert from your WIF from your wallet json.

### Getting a SHA256

The following example is using Javascript using the `crypto-js` package [crypto-js](https://github.com/brix/crypto-js)

```javascript
  var SHA256 = require("crypto-js/sha256");
  var transaction_hash = SHA256('compact_json_string_with_no_spaces_or_new_lines')
```

### Getting your private key from the WIF

In your wallet json next to the public key and address there is a wif. This is a wallet information format key that has the private key inside that is needed for signing.

Here is a function that would acheive this using the Javascript `base64` package [base64](https://github.com/dankogai/js-base64#readme)

```javascript
var getPrivateKeyAndNetworkFromWif = function(wif) {
  var decodedWif = all_crypto.base64.Base64.decode(wif);
  var networkPrefix = decodedWif.substring(0, 1);
  var network = networkPrefix === "M0" ? mainnet : testnet;
  var privateKeyHex = decodedWif.substring(2, decodedWif.length - 6);
  return {
    privateKey: privateKeyHex,
    network: network
  };
};
```

### Signing the transaction hash

Next sign the transaction hash with your private key. This example uses the ED25519 Javascript package `elliptic` [Elliptic](https://github.com/indutny/elliptic)

```javascript
var sign = function(privateKey, message) {
  var ec = new all_crypto.elliptic.eddsa('ed25519');
  var key = ec.keyFromSecret(privateKey);
  var signature = key.sign(all_crypto.buffer.Buffer.from(message, 'utf8')).toHex().toLowerCase();
  return signature;
};
```

The private key is the one you got from the WIF and the message is the transaction\_hash you made earlier. This funciton produces a signature which you then paste into the signature field of the `sender` in the compact json and post to the transaction endpoint `http://mainnet.axentro.io/api/v1/transaction` with the payload wrapped in a `transaction` elements as follows:

```javascript
{"transaction":{"id":"8069e6049f7175229f8e05e5cf4cd5dacbc82cad08bfbd251408b6e980d90b04","action":"send","senders":[{"address":"VDBkYWQxZjZlZjllOTAzYzNiODQ0NmZkZTI4NDBhYmMzYjUxYThjM2E1ZjNkODlj","public_key":"48c45b7e45cd415187216452fa22523e002ca042c2bd7205484f29201c3d5806f90e7aeebad37e3fbe01286c25d4027d3f3fec7b5647eff33c07ebd287b57242","amount":500000000000,"fee":100000000,"signature":"SIGNATURE_GOES_HERE"}],"recipients":[{"address":"VDBlY2I4ZjA5MTUxOWE0MTIwNTRmZjlhYTM1YjYxMjcwNjM1YzcxYjlkMDZhZDUx","amount":500000000000}],"message":"","token":"AXNT",}"prev_hash":"0","timestamp":1529781499,"scaled":1,"kind":"FAST","version":"V1"}
```

This json payload does not need to be compacted and can have spaces and line breaks.


# Crypto

This document outlines the crypto we use to make keypairs, wallets and addresses. We use the ED25519 curve in Axentro.

The following examples are written in Javascript and use these libraries:

* `tweetnacl` package [tweetnacl](https://github.com/dchest/tweetnacl-js)
* `crypto-js` package [crypto-js](https://github.com/brix/crypto-js)
* `base64` package [base64](https://github.com/dankogai/js-base64#readme)

## Creating a keypair

```javascript
var generateValidKeyPair = function myself() {
  var nacl = all_crypto.tweetnacl;
  var keyPair = nacl.sign.keyPair();
  var fullPrivateKey = toHexString(keyPair.secretKey);
  var publicKey = toHexString(keyPair.publicKey);
  var privateKey = fullPrivateKey.replace(publicKey, "");

  return {
    hexPrivateKey: privateKey,
    hexPublicKey: publicKey
  };
};

function toHexString(byteArray) {
  return Array.prototype.map.call(byteArray, function(byte) {
    return ('0' + (byte & 0xFF).toString(16)).slice(-2);
  }).join('');
}
```

## Network Prefix

The network prefix is added to the address to make the final walle address and can be either:

* Mainnet network prefix is: `M0`
* Testnet network prefix is: `T0`

## Creating a wallet address

Once you have a keypair you can use the public key and the network prefix to make a wallet address:

```javascript
var makeAddress = function(publicKey, networkPrefix) {
  var hashedAddress = all_crypto.cryptojs.RIPEMD160(all_crypto.cryptojs.SHA256(publicKey).toString()).toString();
  var networkAddress = networkPrefix + hashedAddress;
  var hashedAddressAgain = all_crypto.cryptojs.SHA256(all_crypto.cryptojs.SHA256(networkAddress).toString()).toString();
  var checksum = hashedAddressAgain.substring(0, 6);
  return all_crypto.base64.Base64.encode(networkAddress + checksum);
};
```

## WIF (Wallet Information Format)

In the Axentro standard wallet format we put the private key in WIF format. You can build the WIF like this:

```javascript
var makeWif = function(privateKey, networkPrefix) {
  var networkKey = networkPrefix + privateKey;
  var hashedKey = all_crypto.cryptojs.SHA256(all_crypto.cryptojs.SHA256(networkKey).toString()).toString();
  var checksum = hashedKey.substring(0, 6);
  return all_crypto.base64.Base64.encode(networkKey + checksum);
};
```

## Getting items out

From a WIF we can get the private key and network type:

```javascript
var getPrivateKeyAndNetworkFromWif = function(wif) {
  var decodedWif = all_crypto.base64.Base64.decode(wif);
  var networkPrefix = decodedWif.substring(0, 1);
  var network = networkPrefix === "M0" ? mainnet : testnet;
  var privateKeyHex = decodedWif.substring(2, decodedWif.length - 6);
  return {
    privateKey: privateKeyHex,
    network: network
  };
};
```

From a private key we can get the public key

```javascript
var getPublicKeyFromPrivateKey = function(privateKey) {
  var ec = new all_crypto.elliptic.eddsa('ed25519');
  var key = ec.keyFromSecret(privateKey);
  var publicKey = toHexString(key.getPublic());
  return publicKey;
};
```


# Setting up & Testing

In order to test locally you can set up a number of nodes locally and connect them together to form a network.

Before you start you need to git clone the axento github repo and build the binaries as described in [Installing](/using-the-cli/install)

There are 2 things a node needs to start up:

* a wallet
* an official\_nodes.yml
* a developer\_fund.yml (not needed but very helpful for testing)

## Official nodes

When you start up a new chain and it writes the genesis block - you must anchor a set of addresses to the chain. At the moment these are fixed once written into the genesis block. There are 2 categories:

* fastnodes
* slownodes

The minimal config is putting your address in both like this:

```bash
vim official_nodes.yml
```

```yaml
fastnodes:
  - VDAyNThiOWFiN2Q5YWM3ZjUyYTNhYzQwZTY1NDBmYWJkMjczZmVmZThlOTgzMWM4
slownodes:
  - VDAyNThiOWFiN2Q5YWM3ZjUyYTNhYzQwZTY1NDBmYWJkMjczZmVmZThlOTgzMWM4
```

If there is not a node with an address that belongs to the official nodes then your nodes will all complain they are not connected to an official network. There is only 1 fast node possible at this time - so you should put only 1 fastnode entry.

Thn supply the official\_nodes.yml file to the node on startup (you should also do the developer\_fund at the same time as they both apply only to the genesis block)

```bash
axen -w your-wallet-address.json --testnet -u http://localhost:3000 -p 3000 -d my_db.sqlite3 --official-nodes=./official_nodes.yml --developer-fund=./developer_fund.yml
```

## Developer Fund

This allows you to specify a set of addresses to populate with instant tokens (you need to do both official\_nodes and developer\_fund at the same time as they both apply only to the genesis block)

```bash
vim developer_fund.yml
```

```yaml
addresses:
  - address: VDAyNThiOWFiN2Q5YWM3ZjUyYTNhYzQwZTY1NDBmYWJkMjczZmVmZThlOTgzMWM4
    amount: "9000000"
  - address: VDA4M2YwYTkzZTQxZTQ0NzdjOGRjMDU4ZTkwZTI4OWY1NDNkMDZjYmU3ODQyM2Rk
    amount: "9000000"
```

Thn supply the official\_nodes.yml file to the node on startup

```bash
axen -w your-wallet-address.json --testnet -u http://localhost:3000 -p 3000 -d my_db.sqlite3 --official-nodes=./official_nodes.yml --developer-fund=./developer_fund.yml
```

## Running multiple nodes for testing

You can run multiple nodes for testing. If you specify a different address for fastnode and slownodes in the official\_nodes config then you can also run a separate node for the fastnode and the other slownodes. Depending on what needs testing.

Start up several nodes connected to each other:

This node is standalone and not connected to a parent:

```bash
axen -w your-wallet-address-1.json --testnet -u http://localhost:3000 -p 3000 -d my_db_1.sqlite3
```

And now connect more nodes to it, or connect nodes to other nodes connected to it. The nodes form a big circle each with a predecessor node and a successor node following the Chord peer to peer networking protocol. So they are not connected in a hierachy but a circle - so it doesn't matter the order you connect the nodes to each other.

It's best to put the nodes in a different folder each. This node connects to the first node

```bash
axen -w your-wallet-address-2.json --testnet -u http://localhost:3001 -p 3001 -d my_db_2.sqlite3 -n http://localhost:3000
```

```bash
axen -w your-wallet-address-3.json --testnet -u http://localhost:3002 -p 3002 -d my_db_2.sqlite3 -n http://localhost:3000
```

```bash
axen -w your-wallet-address-4.json --testnet -u http://localhost:3003 -p 3003 -d my_db_2.sqlite3 -n http://localhost:3000
```

Now you can start miners against one or more of the nodes e.g.

```
axem -w your-wallet.json --testnet -n http://localhost:3000 --process=2
```

or you can use the minaxnt miner for this too.

You can also import any of the wallets into the desktop wallet and change the config in the desktop wallet to point to any of the local nodes. Or you can use the cli client `axe` to send transactions or interact with the nodes.


