Please read the following documents prior to start building on this SDK:
In order to run the interactive tutorial:
make install
make tutorial
Check out the typedoc reference at sdk.atomex.me
Latest version is available on NPM:
npm install atomex-sdk
The Atomex SDK has mainly 2 components:
Atomex
Helpers
class)Currently SDK supports the following currencies/tokens:
XTZ
(tez) — TezosHelpers
ETH
(ether) — EthereumHelpers
Start working with Atomex API by creating an instance of the wrapper class.
const atomex = Atomex.create("testnet")
There are several predefined configs:
mainnet
— for production usetestnet
— for testing purposes, on-chain operations tracked in:localhost
— for Atomex developers only (debugging purposes)Market data can be queried without authentication.
There is also a helper for estimating order price:
Atomex uses simple JWT scheme (without refresh tokens). Client is responsible for tracking the expiration and requesting new tokens.
Read more about the authentication process in the overview.
await atomex.getAuthToken({
timeStamp: 1606227074301,
message: 'Signing in ',
publicKey:
'419491b1796b13d756d394ed925c10727bca06e97353c5ca09402a9b6b07abcc',
signature:
'd937f12e7509f9266376a4cc6b51af91ad9f2e2c55ce9b3dfd870fc2e9d604b390a0f15d7ea277f8b6b9dfc1bb2ef2218d5ec4f87ba0399e6f6fb6d31ed09e03',
algorithm: 'Ed25519:Blake2b'
})
The following structure is returned if everything is ok:
{ "id":
"dd03c7c3bc9daf23727d0c5759c72855eb1f36c9376f8a67b17fcd3dc07bfba1",
"token":
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImRkMDNjN2MzYmM5ZGFmMjM3MjdkMGM1NzU5YzcyODU1ZWIxZjM2YzkzNzZmOGE2N2IxN2ZjZDNkYzA3YmZiYTEiLCJuYmYiOjE2MDYyMzk5OTQsImV4cCI6MTYwNjMyNjM5NCwiaWF0IjoxNjA2MjM5OTk0fQ.ljwKxcQk5mPbRRzZ9qaZioe7U1_3I7riklGCEj2xXPA",
"expires": 1606326394064
}
Assign the token to the Atomex instance:
atomex.setAuthToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImRkMDNjN2MzYmM5ZGFmMjM3MjdkMGM1NzU5YzcyODU1ZWIxZjM2YzkzNzZmOGE2N2IxN2ZjZDNkYzA3YmZiYTEiLCJuYmYiOjE2MDYyMzk5OTQsImV4cCI6MTYwNjMyNjM5NCwiaWF0IjoxNjA2MjM5OTk0fQ.ljwKxcQk5mPbRRzZ9qaZioe7U1_3I7riklGCEj2xXPA")
With auth token assigned we can work with orders:
And swaps:
For each currency create an according helper class instance:
const tez = await TezosHelpers.create("testnet");
You can also specify custom RPC endpoint:
cosnt eth = await EthereumHelpers.create("testnet", "https://goerli.infura.io/v3/12345");
Helpers classes implement a single interface providing methods for interacting with Atomex contracts:
Helpers.buildInitiateTransaction
Helpers.buildAddTransaction
Helpers.buildRedeemTransaction
Helpers.buildRefundTransaction
Encoding/decoding crypto primitives:
Generating data for Atomex.getAuthToken
request:
Estimating fees:
Tracking transaction confirmations and validating parameters:
make install
make
make test
In order to update the OpenAPI specification:
make spec-update
make typedoc
Bump version in package.json, commit & push
make release
Generated using TypeDoc