{"id":21529205,"url":"https://github.com/everx-labs/flex-sdk-js","last_synced_at":"2025-09-03T03:41:25.880Z","repository":{"id":38311378,"uuid":"493248564","full_name":"everx-labs/flex-sdk-js","owner":"everx-labs","description":"Flex Javascript SDK","archived":false,"fork":false,"pushed_at":"2023-11-02T21:36:44.000Z","size":4282,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-08T20:04:15.025Z","etag":null,"topics":["client","dex","ever","evernode","everscale","flex"],"latest_commit_sha":null,"homepage":"https://tonlabs.github.io/flex-sdk-js/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/everx-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-05-17T12:48:27.000Z","updated_at":"2024-10-04T08:25:04.000Z","dependencies_parsed_at":"2023-02-09T12:32:04.328Z","dependency_job_id":"d4123034-d63c-4266-a415-e3c2554938cc","html_url":"https://github.com/everx-labs/flex-sdk-js","commit_stats":null,"previous_names":["everx-labs/flex-sdk-js"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/everx-labs/flex-sdk-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Fflex-sdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Fflex-sdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Fflex-sdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Fflex-sdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/everx-labs","download_url":"https://codeload.github.com/everx-labs/flex-sdk-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Fflex-sdk-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273386828,"owners_count":25096248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","dex","ever","evernode","everscale","flex"],"created_at":"2024-11-24T01:56:13.926Z","updated_at":"2025-09-03T03:41:25.855Z","avatar_url":"https://github.com/everx-labs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flex-sdk-js\n\nFLEX-SDK is a library with convenient facade over the FLEX smart contract system\nand can be used by FLEX maintainers, FLEX traders and others.\n\nThe library is targeted to be used with Node.js applications.\n\nRead the full Flex documentation here https://docs.everos.dev/flex\n\n# Initialize Flex object\n\nLibrary setup is simple, it includes setup for the Everscale client and configuration of the FLEX SDK.\n\nTo get the address of Flex Super Root contract go to the GraphQL playground and run this query:\n\n```\nquery{\n  flex{\n    address\n  }\n}\n```\nNow specify the endpoint URL and Super Root address in the config\nand initialize `flex` object with it. You will need `flex` object later:\n\n```ts\nimport { TonClient } from \"@eversdk/core\";\nimport { libNode } from \"@eversdk/lib-node\";\nimport { Flex, FlexConfig } from \"../flex\";\n\nTonClient.useBinaryLibrary(libNode);\nconst FLEX_CONFIG: Partial\u003cFlexConfig\u003e = {\n    evr: {\n        sdk: {\n            network: {\n                endpoints: [\"FLEX ENDPOINT\"],\n            },\n        },\n    },\n    superRoot: \"Super Root address\",\n};\nconst flex = new Flex(FLEX_CONFIG);\n\n```\n# About Signer parameter\n\nMany functions of FLEX SDK accept parameters named `signer`.\nIt is an object that has a secret, required to sign messages that will be sent to the blockchain.\n\n`signer` parameter can accept these values:\n\n- String containing the secret key of the key pair required to sign messages.\n  Secret key must be represented as a hex string with exactly 64 characters.\n  \n- Instance of the [`Signer` type](https://docs.everos.dev/ever-sdk/reference/types-and-methods/mod_abi#signer) from the `@eversdk/core` library. \n\n- Name of the signer in the [`everdev` signer registry](https://github.com/tonlabs/everdev/blob/main/docs/command-line-interface/signer-tool.md).\n\n# Manage Client and Traders\n\nBefore trading on FLEX you have to prepare some required FLEX actors: Client and Trader.\n\nClient creation requires a wallet with EVER balance that will become an owner\nfor Client contract used to perform management operations of Flex. \n\nGood choice is a Multisig Wallet because it can send payloads to other contracts. \n\nOwner contract means that only this contract can call functions of Client contract. \nOne of the management functions is deploy of a Trader's contract.\n\nLet's deploy Flex Client and then a Trader: \n\n```ts\nconst clientAddress = await Client.deploy(flex, {\n    everWallet: {\n        address: \"0:d807caf6df3a7c2bb0b64915613eca9d8f17ca1de0b938dfdcbb9b4ff30c4526\",\n        signer: \"everWallet private key\",\n    },\n    signer: \"Flex Client private key, can be the same with everWallet signer\",\n    \n});\nconsole.log(`Client: ${clientAddress}}`);\n```\n\nTo deploy a Trader, a person or organization who becomes Trader must generate a pair of keys and provide Flex Client with\n**the pubkey only**.\n\nIf Flex Client will be its only Trader himself, then it can use its Client pubkey. \n\nThen, Flex Client must generate some Trader ID (uint256) that must be unique for each of its Trader. \n\n\nWe already generated some ID and have a Trader pubkey, let's deploy Trader contract:\n\n```ts\n// Client deploys Trader's contract (`userIdIndex` contract)\n\nawait Trader.deploy(flex, {\n    client: {\n        address: clientAddress,\n        signer: \"Client private key\",\n    },\n    id: traderId,\n    name: \"any name\",\n    pubkey: \"162c6c708018da073729dd4a60118425dd917e44653383f1faed4d16b94af30b\" // Trader's pubkey\n});\n\n```\n\n# Deposit on Flex\n\nYou can deposit EVERs and Tip3 tokens on Flex.\n\n## Deposit EVERs\n\nTo deposit evers, transfer them to the Ever Vault contract. Specify Trader ID.\n\n```ts\nlet trader_ever_wallet =  await Trader.deployEverWallet(flex, {\n    clientAddress: clientAddress,\n    everWallet: {\n        address: \"0:d677caf6df3a7c2bb0b64915613eca9d8f17ca1de0b938dfdcbb9b4ff30c4526\",\n        signer: \"everWallet\",\n    },\n    tokens: 100,\n    evers: 20,\n    keepEvers: 15,\n    traderId: traderId,\n    wrapperAddress: \"0:c072805ae38d548d4abbaddf929659d37584117b63b0969eb3f812c6252b12fb\", // EVER wrapper address\n});\n\nconsole.log(`Trader EVER wallet address: ${trader_ever_wallet} has beed topped-up.`);\n\n```\n\n## Deposit Tip3 tokens\n\nTo deposit Tip3 tokens, transfer them from Tip3 wallet to the Flex Vault contract.\nSpecify Trader ID. \n\n```ts\nlet trader_tip3_wallet =  await Trader.deployTip31Wallet(flex, {\n    clientAddress: clientAddress, \n    everWallet: {\n        address: \"0:d677caf6df3a7c2bb0b64915613eca9d8f17ca1de0b938dfdcbb9b4ff30c4526\",\n        signer: \"everWallet\",\n    },\n    traderId: traderId,\n    tokenWalletAddress: \"0:d4208262595226ac069b94d716ec6339882ec93a0e7e254186f3eb77b7d34c4b\", // tip3 wallet owned by everWallet\n    tokenWrapperAddress: \"0:d51c96406f74e4a1168f5ca3a936330beb7653782743cdce23c11d285c92f9ca\", // Token Wrapper address on Flex\n    tokenWrapperWalletAddress: \"0:ca4a6787b720f38745ec2a13f997061a7ba3dfa2e9b4432771a9cf61ea6ac984\", // tip3 vault contract of the Token Wrapper\n    tokenUnits: \"100000000000\", // tokens to deposit\n    transferEvers: 21,\n    evers: 20,\n    keepEvers: 15\n}\n);\n\nconsole.log(`Trader Tip3 wallet address: ${trader_tip3_wallet} has beed topped-up.`);\n\n```\n\n# Trading\n\n## Orders\n\nTrader needs to have 2 wallets for each currency in a Pair to trade in that Pair. \nGo to the Deposit sections to read how to top-up token wallets.\n\n```ts\nawait Trader.makeOrder(\n    flex,\n    {\n        clientAddress: clientAddress,\n        trader: {\n            id: traderId,\n            signer: `Trader's private key`\n        },\n        sell: true,\n        marketAddress: marketAddress, // Trading pair address\n        price: 2.6,\n        amount: 18,\n    },\n);\n```\n\n# Examples\n\nYou can examine the `examples` folder for a lot of examples. \nTo build run\n```\nnpm run build\n```\n\nTo run an example do\n\n```bash \ncd dist/examples\nnode \u003cexample name\u003e\n```\n\n# CLI\n\nThe major part of library functionality is accessible via command line interface flex-cli.\n\nTo use command line interface run command `npm run cli command [options] \u003carguments\u003e`.\n\nYou can get help on CLI running `npm run cli --help`.\n\n# Remarks for the FLEX SDK Developers\n\nFLEX SDK contains folder `contracts` with TS wrappers of all contracts used in \nFLEX contract system. \nPlease note that at the moment, Flex library syncronizes contracts from the private repository. \n\nTo update FLEX contract wrappers you have to perform following steps:\n\n- Clone `ton-contracts` repository aside of `flex-sdk-js` folder.\n- Checkout `ton-contracts` repo on required branch.\n- Run `npm run update-contracts` inside of `flex-sdk-js` folder.\n\nAfter that step the `flex-sdk-js` library can stop to compile.\nYou have to perform changes in library code to reflect changes in \nFLEX contract system if required.\n\n# TESTS\n\n## Install\n\n```bash \nnpm i\nnpm run build\n```\n\n## Unit Tests\n\n```bash \nnpm t\n```\n\n## Integration Tests\n\n### Configure\n\nCreate config file.\nConfig file must be located and named as `flex-sdk-js/.secret/integration-test-config.json`.\n\n```json\n{\n    \"flex\": {\n        \"evr\": {\n            \"sdk\": {\n                \"network\": {\n                    \"endpoints\": [\n                        \"https://devnet.evercloud.dev/\u003cevercloud-project-id\u003e/graphql\"\n                    ]\n                }\n            }\n        },\n        \"superRoot\": \"0:7a6d3ab04ab26333d6e0523410b60d9f4bc55913e4c0291010c8314e9e47d169\"\n    },\n    \"everWallet\": {\n        \"address\": \"\u003cever-wallet-address\u003e\",\n        \"signer\": \"\u003cever-wallet-signer\u003e\"\n    },\n    \"client\": {\n        \"address\": \"\u003cflex-client-address\u003e\",\n        \"signer\": \"\u003cflex-client-signer\u003e\"\n    },\n    \"trader\": {\n        \"signer\": \"\u003cflex-trader-signer\u003e\"\n    },\n    \"market\": \"0:a8f3f3bfafcac2adf95b62670aa01fbf610a103ce7029dc5f13cab4f0a7edfe8\",\n    \"EVER\": {\n        \"wrapper\": \"0:1cc3596e2db5cc92d0e02f55526f8aec949924ef320d72b763a5f4aafcca3e30\",\n        \"wallet\": {\n            \"address\": \"\u003cever-token-wallet-address\u003e\",\n            \"signer\": \"\u003cever-token-wallet-signer\u003e\"\n        }\n    },\n    \"TSDT\": {\n        \"wrapper\": \"0:b550a9138452d36d0a1e38edebac0063f3126e4d7a4cf593e6c090faa2ec0523\",\n        \"wrapperWallet\": \"0:c304ee549051d5500877f2fc796bb81e3f9cfde2b1b62de0eb360804ab7fe661\",\n        \"wallet\": {\n            \"address\": \"\u003ctsdt-token-wallet-address\u003e\",\n            \"signer\": \"\u003ctsdt-token-wallet-signer\u003e\"\n        }\n    }\n}\n```\n\nWhere:\n\n- `\u003cever-wallet-address\u003e` and `\u003cever-wallet-signer\u003e` is a main ever wallet.\n  If you omit address, it will be calculated from signer's public key.\n  This wallet must have enough balance to perform all integration test.\n\n- `\u003cflex-client-address\u003e` and `\u003cflex-client-signer\u003e` is a FlexClient account. \n  \n- `\u003cflex-trader-signer\u003e` is a traders keys used in trading operations. Public key of this signer is\n  used as a `traderId`.\n\n- `\u003cever-token-wallet-address\u003e` and `\u003cever-token-wallet-signer\u003e` is a multisig wallet that will be \n  used as an external EVER wallet.  \n  If you omit address, it will be calculated from signer's public key.\n  Usually it is the same as a main ever wallet.\n\n- `\u003ctsdt-token-wallet-address\u003e` and `\u003ctsdt-token-wallet-signer\u003e` is a TSDT TIP3 Token Wallet that will be used\n  as an external TSDT wallet.\n  Usually this wallet is related to the main ever wallet. So `\u003ctsdt-token-wallet-signer\u003e` is equal to\n  the `\u003cever-wallet-signer\u003e`.\n\nRecommended signer names:\n- `flex-ever-wallet` for `\u003cever-wallet-signer\u003e`.\n- `flex-client` for `\u003cflex-client-signer\u003e`.  \n- `flex-trader` for `\u003cflex-trader-signer\u003e`.\n- `flex-ever-token-wallet` for `\u003cever-token-wallet-signer\u003e`.\n- `flex-tsdt-token-wallet` for `\u003ctsdt-token-wallet-signer\u003e`.\n\n### Prepare\n\nIf you have no deployed trader and token wallets yet, you can do it with `prepare` script.  \n\n```bash\nnpm run integration-test-prepare\n```\n\n### Run\n\n```bash \nnpm run integration-test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverx-labs%2Fflex-sdk-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feverx-labs%2Fflex-sdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverx-labs%2Fflex-sdk-js/lists"}