REST API for interacting with Libra testnet. This solution allows to access existing or create new accounts, mint and transfer coins, view transaction history etc. on the testnet.
Requirements:
- Node.js (12.0.0 or newer)
Setup:
- install Node.js
- clone the repository:
git clone https://github.com/trifinityio/libra-api.git
- change into the root directory:
cd libra-api
- install all Node.js dependencies from
package.json
:npm install
- copy env.example as .env and adjust values:
cp env.example .env
(optional) - start:
npm start
All endpoints use the POST
method and use JSON
as both input and output.
Create new account and provide it with predefined amount of tokens.
No parameters.
Example output:
{
"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"mnemonic": "learn similar drop bus donor divert choice motor february skull ghost escape habit able develop setup feel fan address found armed demise three wood",
"balance":"1000000000"
}
Get public address for given mnemonic
.
Parameters:
mnemonic
(required)
Example output:
{
"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385"
}
Get balance for given address
.
Parameters:
address
(required)
Example output:
{
"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"balance": "1000000000"
}
Get recent transaction history for given address
.
Parameters:
address
(required)
Example output:
{
"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"transactions": [
{
"amount": "1000000000",
"date": "2019-07-25T20:07:04Z",
"event": "mint",
"explorerLink": "https://libexplorer.com/version/47524",
"fromAddress": "0000000000000000000000000000000000000000000000000000000000000000",
"toAddress": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"transactionVersion": 47524,
"type": "mint_transaction"
},
{
"amount": "1",
"date": "2019-07-26T12:33:07Z",
"event": "sent",
"explorerLink": "https://libexplorer.com/version/81760",
"fromAddress": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"toAddress": "3c745e0439cc813a07dec2dcd06b0717bd203c16311b37c96d630673958b2587",
"transactionVersion": 81760,
"type": "peer_to_peer_transaction"
},
{
"amount": "1",
"date": "2019-07-26T12:38:14Z",
"event": "received",
"explorerLink": "https://libexplorer.com/version/81939",
"fromAddress": "111a4302d2dd2ba1173024208d09bfead3ac0ef6bb66cfb5b7b4cb15ddbd85d1",
"toAddress": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"transactionVersion": 81939,
"type": "peer_to_peer_transaction"
}
]
}
Transfer amount
of coins to toAddress
from account corresponding to given mnemonic
.
Parameters:
mnemonic
(required)toAddress
(required)amount
(required)
Example output:
{
"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"toAddress": "3c745e0439cc813a07dec2dcd06b0717bd203c16311b37c96d630673958b2587",
"amount": 1
}
Mint amount
of coins to address
.
Parameters:
address
(required)amount
(required)
Example output:
{
"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
"amount": 123
}