{"id":18359602,"url":"https://github.com/starkware-libs/starkex-js","last_synced_at":"2025-04-06T13:32:07.981Z","repository":{"id":37486654,"uuid":"431504948","full_name":"starkware-libs/starkex-js","owner":"starkware-libs","description":"JavaScript SDK for StarkEx","archived":false,"fork":false,"pushed_at":"2023-11-09T05:46:32.000Z","size":274,"stargazers_count":32,"open_issues_count":2,"forks_count":17,"subscribers_count":12,"default_branch":"dev","last_synced_at":"2025-03-22T01:24:41.104Z","etag":null,"topics":["blockchain","ethereum","javascript","nodejs","sdk","starkex","starkware","typescript"],"latest_commit_sha":null,"homepage":"https://starkware.co/starkex/api/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/starkware-libs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2021-11-24T13:58:16.000Z","updated_at":"2025-02-06T14:42:55.000Z","dependencies_parsed_at":"2024-11-05T22:29:19.717Z","dependency_job_id":"162ab648-48b9-4a9a-b1e7-c40fdb7ce62d","html_url":"https://github.com/starkware-libs/starkex-js","commit_stats":{"total_commits":53,"total_committers":4,"mean_commits":13.25,"dds":"0.37735849056603776","last_synced_commit":"f23770e9709a0e84a55b2795696ac3a2792ba1bf"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkware-libs%2Fstarkex-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkware-libs%2Fstarkex-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkware-libs%2Fstarkex-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starkware-libs%2Fstarkex-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starkware-libs","download_url":"https://codeload.github.com/starkware-libs/starkex-js/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247488640,"owners_count":20946975,"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","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":["blockchain","ethereum","javascript","nodejs","sdk","starkex","starkware","typescript"],"created_at":"2024-11-05T22:23:42.331Z","updated_at":"2025-04-06T13:32:05.875Z","avatar_url":"https://github.com/starkware-libs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- logo --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg width='300' src=\"https://raw.githubusercontent.com/starkware-libs/starkex-js/master/img/starkex.svg\"\u003e\n\u003c/p\u003e\n\n\u003c!-- tag line --\u003e\n\u003ch4 align='center'\u003e JavaScript SDK for StarkEx\u003c/h4\u003e\n\n\u003c!-- primary badges --\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.typescriptlang.org/\"\u003e\n    \u003cimg src='https://badges.aleen42.com/src/typescript.svg' /\u003e\n  \u003c/a\u003e \n  \u003ca href=\"https://www.npmjs.com/package/@starkware-industries/starkex-js\"\u003e\n    \u003cimg src='https://img.shields.io/github/package-json/v/starkware-libs/starkex-js?label=npm' /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://starkware.co/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/powered_by-StarkWare-navy\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n`starkex-js` is a JavaScript wrapper around the [StarkEx API](https://starkware.co/starkex/api/)\nthat can be used in both NodeJS and Browser environments.\n\n`starkex-js` is written in [ECMAScript6] and strongly typed and transpiled to ECMAScript5 using [TypeScript].\n\n[typescript]: https://www.typescriptlang.org/\n[ecmascript6]: https://github.com/ericdouglas/ES6-Learning#articles--tutorials\n\n## Installation\n\n_This package is Typescript ready_\n\n```bash\n// using npm\nnpm i @starkware-industries/starkex-js\n\n// using yarn\nyarn add @starkware-industries/starkex-js\n```\n\n## How to use it\n\nThe library is a default export.\n\n### Browser\n\nTo use it browser, you need to use the code from `browser.js` file.\n\n```html\n\u003cscript src=\"path-to-local-library/browser.js\"\u003e\u003c/script\u003e\n```\n\nor via CDN\n\n```html\n\u003cscript src=\"https://path-to-cdn-library/browser.js\"\u003e\u003c/script\u003e\n```\n\nIn this scenario, the library will be bound to the global window object with the property StarkExAPI.\n\n`window.StarkExAPI` or simple `StarkExAPI` can be used to access the library.\n\nIf you have a toolchain available you can use an `import` statement.\n\n```ts\nimport StarkExAPI from '@starkware-industries/starkex-js/browser';\n```\n\n```js\nconst StarkExAPI = require('@starkware-industries/starkex-js/browser');\n```\n\n_Because is a default export, here you can import it with what name you want_\n\n### Node\n\nFor `NodeJS` environment, just replace `browser` with `node`\n\n```ts\nimport StarkExAPI from 'starkex-js/node';\n```\n\n```js\nconst StarkExAPI = require('@starkware-industries/starkex-js/node');\n```\n\n## Usage\n\nThe object imported is a class that first needs to be instantiated:\n\n```ts\nnew StarkExAPI(config: StarkExClientConfig): StarkExClient;\n```\n\nWhere `config` is a configuration object of form:\n\n```ts\ninterface StarkExClientConfig {\n  endpoint: string;\n  // optional - relevant only for node environment\n  certs?: {\n    cert: string;\n    key: string;\n    ca?: string;\n  };\n}\n```\n\n_Example_\n\n```ts\nconst starkExAPI = new StarkExAPI({\n  endpoint: 'https://gw.playground-v2.starkex.co'\n});\n```\n\n_Example with certs (NodeJS environment)_\n\n```ts\nconst starkExAPI = new StarkExAPI({\n  endpoint: 'https://playground.starkex.co',\n  certs: {\n    cert: 'USER_CERT',\n    key: 'USER_KEY'\n  }\n});\n```\n\nThe `StarkExClient` object returned from the constructor exposing the different gateways existing on this API:\n\n#### `public gateway: Gateway`\n\nThis is the StarkEx Services HTTP gateway version2 for all external trading interactions.\n\n_Example for is_alive_\n\n```ts\nconst isAlive = await starkExAPI.gateway.isAlive();\nconsole.log(isAlive); // gateway is alive!\n```\n\n_Example for get_first_unused_tx_id_\n\n```ts\nconst txId = await starkExAPI.gateway.getFirstUnusedTxId();\nconsole.log(txId); // 69\n```\n\n_Example for a DepositRequest_\n\n```ts\nconst request = {\n  txId: 10234993,\n  amount: \"4029557120079369747\",\n  starkKey: \"0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac\",\n  tokenId: \"0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378\",\n  vaultId: 1654615998\n};\nconst response = await starkExAPI.gateway.deposit(request);\nconsole.log(response); // {txId: 10234993, code: \"TRANSACTION_PENDING\"}\n```\n\n_Example for a MultiTransactionRequest_\n\n```ts\nconst response = await starkExClient.gateway.multiTransaction({\n  txId: 10234994,\n  txs: [\n    {\n      type: StarkExClient.GatewayRequestType.DEPOSIT_REQUEST,\n      amount: \"4029557120079369747\",\n      starkKey: \"0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac\",\n      tokenId: \"0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378\",\n      vaultId: 1654615998\n    },\n    {\n      type: StarkExClient.GatewayRequestType.WITHDRAWAL_REQUEST,\n      amount: \"4029557120079369747\",\n      starkKey: \"0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac\",\n      tokenId: \"0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378\",\n      vaultId: 1654615998\n    },\n  ],\n});\nconsole.log(response); // {txId: 10234994, code: \"TRANSACTION_PENDING\"}\n```\n\nFull API docs for `gateway` can be found [here](docs/classes/Gateway.md).\n\n#### `public feederGateway: FeederGateway`\n\nThis is the StarkEx Services HTTP gateway for feeder interactions. The Feeder is a gateway to the StarkEx system for\nretrieving transaction batch information by external parties\n\n_Example for get_batch_ids_\n\n```ts\nconst batchIdsRequest = {\n  vaultRoot: '0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1',\n  orderRoot: '0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8',\n  sequenceNumber: 5678\n};\nconst batchIds = await starkExAPI.feederGateway.getBatchIds(batchIdsRequest);\nconsole.log(batchIds); // [123, 456]\n```\n\nFull API docs for `feederGateway` can be found [here](docs/classes/FeederGateway.md).\n\n_Deprecated functionality_\n\nSince StarkEx v4.5, `gateway` and `feeder gateway` apis expect to receive http requests for version 2 (`v2` prefix inside the request url).\n\nDeprecated functions, that still uses the old version of the StarkEx api (no url prefix), are marked with a `DEPRECATED` prefix by the SDK. This was done in order to inform the user that even though those methods are still supported by the api, they will be deleted in the next version.\n\nFor example, a request to `/v2/feeder_gateway/get_batch_info` will be made by:\n\n```ts\nawait starkExAPI.feederGateway.getBatchInfo(1);\n```\n\nWhile:\n\n```ts\nawait starkExAPI.feederGateway.DEPRECATED_getBatchInfo(1);\n```\n\nwill make a request to `/feeder_gateway/get_batch_info`.\n\n---\n\nNote: All results will be exactly the **raw** response from the API.\n\n## API Docs\n\n[Click here](docs/modules.md) for full API documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkware-libs%2Fstarkex-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarkware-libs%2Fstarkex-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkware-libs%2Fstarkex-js/lists"}