Quick Integration Guide
Last updated
Last updated
Flex JS SDK repository:
Flex JS SDK Reference:
GraphQL API TestNet Playground: . Observe Flex API documentation under Flex
root query
General Flex Documentation:
This is a one-page document to kick-off integration of your project with Flex.
There are 2 possible integration scenarios:
You have your own funds to operate on Flex: perform such operations as deposit, trade and withdraw.
You have funds delegated from another party and will perform only trading on Flex.
Flex Client - Entity that manages Flex funds: deposits tokens, adds Traders, delegates tokens to Traders and revokes tokens from Traders.
Trader - Entity that performs trading operations on flex: makes orders, cancel orders. Each trader has an ID and an index contract deployed for that ID. Index contract is also used to pay gas for Flex operations.
To work on Flex in devnet, use your devnet Evercloud endpoint, to work on Flex in mainnet use your mainnet endpoint:
To open playground click on the play button.
⚠️ You need to add your projectID to the url inside the playground to access it.
Go to the GraphQL playground and get Super Root address with this query
Configure Flex SDK with the superRoot
address and endpoint.
First, you need to have a wallet with EVERs to start the whole process.
Transfer EVERs to this wallet
Retrieve the Seed Phrase from the wallet (12 or 24 words).
Now you have only EVERs.
You can either deposit EVERs or TIP 3.2 Tokens to Flex.
If you want to deposit TIP 3.2 as well, then you need to swap some of your EVERS to TIP 3.2.
Let’s find out what TIP 3.2 tokens are traded on Flex.
Run this query to see the available pairs and their token tickers:
After you swapped tokens, you are ready to deposit both EVER and TIP 3.2 tokens on Flex.
Now you need to identify your TIP 3.2 wallet addresses. You will need them later, to deposit on Flex.
To manage funds on Flex, you need to have a Flex Client contract. Let’s create it.
First, you need to prepare Flex Client Signer to deploy it.
Go to your EVER wallet and export the Seed Phrase. Then run this
Now you can use either alias “everWallet” or keys.secret string as signer
to work with your Flex Client.
⚠️ If you already deployed Flex Client via DeBot, you don’t need to perform this step. But if you can not find Flex Client address in your DeBot - you can run Client.deploy to find it. Deploy will not work twice, don’t worry about your funds.
If you, as a company or person, are going to both manage funds and trade, you should also deploy Trader and delegate it some funds.
First, you need to get the Trader’s public key. Let’s generate a key pair for the Trader. If you don’t want to have responsibility for the trader’s keys, ask the person who is going to be the trader, to generate the key pair and give you the pubkey.
To deploy the Trader you need to have 40 EVERs on Flex Client contract. This value can be changed in flex-sdk-js config.
Flex Client deploys the Trader’s index contract:
In order to deposit tokens on Flex you need to know Flex Token Wrapper addresses and Flex Token Vault address.
Use Flex query to get all Pairs information.
☝🏻 Note that EVER wrapper does not have a Tip 3.2 Token Wallet address. EVERs are deposited directly into the wrapper.
Take your Trader credentials (client address and traderId) and check Trader balances now
When trading on Flex with delegated funds, Trader can perform only MakeOrder/CancelOrder operations, meanwhile Flex Client can revoke funds at any moment.
So, if this is your case, you need to generate your pair of keys and give your pubkey (not private key!) to the person who owns Flex Client and manages the funds.
If you both manage funds and trade, refer to the first section: How to go on Flex with your funds.
At first you need to generate your keypair that will only be stored on your side.
⚠️ No one, including the Funds delegator should have access to your private key or seed phrase.
Its public key will be used to deploy Trader’s wallet with delegated funds limited to executing trades on Flex only.
Now you can use either “traderSigner” (everdev keypair name) or “d28777ee18fe68ec152e1569018b5e61e33918ff304a8eff6d6c5ed98df63a35” string as signer
parameter in Flex SDK below.
After it is installed, you can use TONOS-CLI to generate your pair of keys.
First create your seed phrase:
Back up your seed phrase safely, your keys can always be restored from it.
To create a key pair file from a seed phrase use the following command:
<keyfile.json>
- the resulting file the key pair will be written to. "<seed_phrase>"
- seed phrase generated on the previous save.
Example:
Give your generated pubkey to the person who manages funds on Flex (owner of Flex Client).
That person will provide you with these credentials:
ID
name
Client address
Wallets with wrapped tokens
After you have been delegated some funds, you can check your balances like this:
Now, it’s time to make an order.
You will need:
trader signer - the pair of keys you generated above. You can use everdev signer name or private key hex string as a signer
marker address - trading pair address. You can query available pairs in the GraphQL playground with this query. Check documentation in the playground for other available fields:
By default IOP
order will be created.
Trade operations use gas and are subject to fees, so, in order to check that your balances have enough money, you can use Trader.
Balances that require top-up are: User Index contract and all Flex Wallets. This function tops them all up to the minimum balance you specify, and, if you need, add more on top.
Register in Evercloud to get your endpoint .
Install either or for that.
Now you know the symbol (ticker) of TIP 3.2 token and you can use any swap tool to swap EVERs (or other TIP.2 tokens you have) to this TIP 3.2: use Surf , or .
You can use , like this:
You can use tool for key management.
You can use tool for key management.
You can use to generate keys.
You can use to install the latest version of TONOS-CLI.
You can check the full list of order types here:
How to run samples →
Samples →
How to run tests →
Tests →