REST API client for Connext
REST API client manages multiple channels for Connext network using a single mnemonic to create accounts for each index on the Ethereum standard derivation path.
To get started you will need to setup an environment file (.env
) with the following three variables:
CONNEXT_ETH_PROVIDER_URL=""
CONNEXT_NODE_URL=""
CONNEXT_MNEMONIC=""
There are two ways to get running with the REST API client using either Docker or NodeJS.
Make sure you have Docker installed globally then run using the environment file we created and expose port 5040 using our published image on DockerHub
docker run --env-file .env -p 5040:5040 connextproject/rest-api-client
Make sure you have NodeJS installed globally and install the required dependencies with the following command:
npm install
Then run the following command from the root directory of this repository and ensure the environment file should also be available in the root directory.
npm run start
In this example we will demonstrate how to create two Wallet accounts, connect them to the Connext node and then deposit to one account and make a transfer to the other.
We will be using the following environment variables for this example:
CONNEXT_MNEMONIC=rich awful vocal decade chaos horse cheese sadness just equip equip dismiss
CONNEXT_ETH_PROVIDER_URL=https://staging.indra.connext.network/api/ethprovider
# note: don't include a trailing "/" in URL
CONNEXT_NODE_URL=https://staging.indra.connext.network
- Create account A
POST http://localhost:5040/create
Content-Type: application/json
{
"index": 0
}
### publicIdentifier: indra53QJ6exujj3pQQ8BPuTDfQqBXvpyzkz8uS4fwbNMtMZKQZWuUS
### address: 0x44A0ac8eEaCa8D3B51CD3c6a2C23C618d3a2eB63
- Create account B
POST http://localhost:5040/create
Content-Type: application/json
{
"index": 1
}
### publicIdentifier: indra6FHtEpVbRgT221fN95REhxXHqeZrV4fJiv9TbG5FuwjrhUfcZ9
### address: 0x098158D8B59327C5EcA50A299151D69182b36A4b
- Connect account A
POST http://localhost:5040/connect
Content-Type: application/json
{
"publicIdentifier": "indra53QJ6exujj3pQQ8BPuTDfQqBXvpyzkz8uS4fwbNMtMZKQZWuUS"
}
- Connect account B
POST http://localhost:5040/connect
Content-Type: application/json
{
"publicIdentifier": "indra6FHtEpVbRgT221fN95REhxXHqeZrV4fJiv9TbG5FuwjrhUfcZ9"
}
-
Send some ETH to account A's address (on Rinkeby for this example)
-
Deposit ETH on channel for account A
POST http://localhost:5040/deposit
Content-Type: application/json
{
"amount": "10000000000000000",
"assetId": "0x0000000000000000000000000000000000000000",
"publicIdentifier": "indra53QJ6exujj3pQQ8BPuTDfQqBXvpyzkz8uS4fwbNMtMZKQZWuUS"
}
- Create linked transfer with account B as recipient
POST http://localhost:5040/linked-transfer
Content-Type: application/json
{
"amount": "10000000000000000",
"assetId": "0x0000000000000000000000000000000000000000",
"recipient": "indra6FHtEpVbRgT221fN95REhxXHqeZrV4fJiv9TbG5FuwjrhUfcZ9",
"publicIdentifier": "indra53QJ6exujj3pQQ8BPuTDfQqBXvpyzkz8uS4fwbNMtMZKQZWuUS"
}
- Check ETH balance for account B
GET http://localhost:5040/balance/0x0000000000000000000000000000000000000000/indra6FHtEpVbRgT221fN95REhxXHqeZrV4fJiv9TbG5FuwjrhUfcZ9
There are more example requests on the examples
directory in the format of .http
files which can be executed using a VSCode Extension if you would like: Rest Client Extension for VSCode
You can find Swagger docs on the interface here: http://18.223.112.148:5040/documentation/static/index.html#/