Skip to content

trifinityio/libra-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libra REST API

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.

Installation

Requirements:

Setup:

  1. install Node.js
  2. clone the repository: git clone https://github.com/trifinityio/libra-api.git
  3. change into the root directory: cd libra-api
  4. install all Node.js dependencies from package.json: npm install
  5. copy env.example as .env and adjust values: cp env.example .env (optional)
  6. start: npm start

Endpoints

All endpoints use the POST method and use JSON as both input and output.

/createWallet

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"
}

/getAddress

Get public address for given mnemonic.

Parameters:

  • mnemonic (required)

Example output:

{
	"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385"
}

/getBalance

Get balance for given address.

Parameters:

  • address (required)

Example output:

{
	"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
	"balance": "1000000000"
}

/transactionHistory

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

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

Mint amount of coins to address.

Parameters:

  • address (required)
  • amount (required)

Example output:

{
	"address": "3a6ef6397077322301a50eeae52205b7dcc3e09ba2f1560008abe4a15f1f6385",
	"amount": 123
}

Releases

No releases published

Packages

No packages published