{"id":13517837,"url":"https://github.com/stellar/js-stellar-sdk","last_synced_at":"2025-05-13T21:07:44.386Z","repository":{"id":30134661,"uuid":"33684726","full_name":"stellar/js-stellar-sdk","owner":"stellar","description":"Main Stellar client library for the JavaScript language.","archived":false,"fork":false,"pushed_at":"2025-04-21T22:30:17.000Z","size":19882,"stargazers_count":657,"open_issues_count":104,"forks_count":325,"subscribers_count":81,"default_branch":"master","last_synced_at":"2025-05-06T06:49:10.501Z","etag":null,"topics":["blockchain","cryptocurrency","horizon","javascript","sdk","stellar"],"latest_commit_sha":null,"homepage":"https://stellar.github.io/js-stellar-sdk/","language":"JavaScript","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/stellar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-04-09T18:14:00.000Z","updated_at":"2025-04-27T19:24:09.000Z","dependencies_parsed_at":"2023-12-14T20:30:54.665Z","dependency_job_id":"10d06c30-c032-40fa-96a3-12401121a341","html_url":"https://github.com/stellar/js-stellar-sdk","commit_stats":{"total_commits":891,"total_committers":95,"mean_commits":9.378947368421052,"dds":0.7564534231200898,"last_synced_commit":"b13c291f772bfbb25e42fd39ff513d6d58196dde"},"previous_names":[],"tags_count":163,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stellar%2Fjs-stellar-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stellar%2Fjs-stellar-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stellar%2Fjs-stellar-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stellar%2Fjs-stellar-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stellar","download_url":"https://codeload.github.com/stellar/js-stellar-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254028831,"owners_count":22002279,"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","cryptocurrency","horizon","javascript","sdk","stellar"],"created_at":"2024-08-01T05:01:37.947Z","updated_at":"2025-05-13T21:07:44.170Z","avatar_url":"https://github.com/stellar.png","language":"JavaScript","readme":"\n\u003cdiv align=\"center\"\u003e\n  \u003cimg alt=\"Stellar\" src=\"https://github.com/stellar/.github/raw/master/stellar-logo.png\" width=\"558\" /\u003e\n  \u003cbr/\u003e\n  \u003cstrong\u003eCreating equitable access to the global financial system\u003c/strong\u003e\n  \u003ch1\u003ejs-stellar-sdk\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://badge.fury.io/js/@stellar%2Fstellar-sdk\"\u003e\u003cimg src=\"https://badge.fury.io/js/@stellar%2Fstellar-sdk.svg\" alt=\"npm version\" height=\"18\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@stellar/stellar-sdk\"\u003e\n    \u003cimg alt=\"Weekly Downloads\" src=\"https://img.shields.io/npm/dw/@stellar/stellar-sdk\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/stellar/js-stellar-sdk/actions/workflows/tests.yml\"\u003e\u003cimg alt=\"Test Status\" src=\"https://github.com/stellar/js-stellar-sdk/actions/workflows/tests.yml/badge.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\njs-stellar-sdk is a JavaScript library for communicating with a\n[Stellar Horizon server](https://github.com/stellar/go/tree/master/services/horizon) and [Soroban RPC](https://developers.stellar.org/docs/data/rpc).\nIt is used for building Stellar apps either on Node.js or in the browser, though it can be used in other environments with some tinkering.\n\nIt provides:\n\n- a networking layer API for Horizon endpoints (REST-based),\n- a networking layer for Soroban RPC (JSONRPC-based).\n- facilities for building and signing transactions, for communicating with a\n  Stellar Horizon instance, and for submitting transactions or querying network\n  history.\n\n**Jump to:**\n\n * [Installation](#installation): details on hitting the ground running\n * [Usage](#usage): links to documentation and a variety of workarounds for non-traditional JavaScript environments\n   - [...with React Native](#usage-with-react-native)\n   - [...with Expo](#usage-with-expo-managed-workflows)\n   - [...with CloudFlare Workers](#usage-with-cloudflare-workers)\n * [Developing](#developing): contribute to the project!\n * [Understanding `stellar-sdk` vs. `stellar-base`](#stellar-sdk-vs-stellar-base)\n * [License](#license)\n\n## Installation\n\nUsing npm or yarn to include `stellar-sdk` in your own project:\n\n```shell\nnpm install --save @stellar/stellar-sdk\n# or\nyarn add @stellar/stellar-sdk\n```\n\nThen, require or import it in your JavaScript code:\n\n```js\nvar StellarSdk = require('@stellar/stellar-sdk');\n// or\nimport * as StellarSdk from '@stellar/stellar-sdk';\n```\n\n(Preferably, you would only import the pieces you need to enable tree-shaking and lower your final bundle sizes.)\n\n### Browsers\n\nYou can use a CDN:\n\n```html\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/{version}/stellar-sdk.js\"\u003e\u003c/script\u003e\n```\n\nNote that this method relies on using a third party to host the JS library. This may not be entirely secure. You can self-host it via [Bower](http://bower.io):\n\n```shell\nbower install @stellar/stellar-sdk\n```\n\nand include it in the browser:\n\n```html\n\u003cscript src=\"./bower_components/stellar-sdk/stellar-sdk.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  console.log(StellarSdk);\n\u003c/script\u003e\n```\n\nIf you don't want to use or install Bower, you can copy the packaged JS files from the [Bower repo](https://github.com/stellar/bower-js-stellar-sdk), or just build the package yourself locally (see [Developing :arrow_right: Building](#building)) and copy the bundle.\n\n| Always make sure that you are using the latest version number. They can be found on the [releases page](https://github.com/stellar/js-stellar-sdk/releases) in GitHub. |\n|----|\n\n### Custom Installation\n\nYou can configure whether or not to build the browser bundle with the axios dependency. In order to turn off the axios dependency, set the USE_AXIOS environment variable to false. You can also turn off the eventsource dependency by setting USE_EVENTSOURCE to false.\n\n#### Build without Axios\n```\nnpm run build:browser:no-axios\n```\nThis will create `stellar-sdk-no-axios.js` in `dist/`.\n\n#### Build without EventSource\n```\nnpm run build:browser:no-eventsource\n```\nThis will create `stellar-sdk-no-eventsource.js` in `dist/`.\n\n#### Build without Axios and Eventsource\n```\nnpm run build:browser:minimal\n```\nThis will create `stellar-sdk-minimal.js` in `dist/`.\n\n## Usage\n\nThe usage documentation for this library lives in a handful of places:\n\n * across the [Stellar Developer Docs](https://developers.stellar.org), which includes tutorials and examples,\n * within [this repository itself](https://github.com/stellar/js-stellar-sdk/blob/master/docs/reference/readme.md), and\n * on the generated [API doc site](https://stellar.github.io/js-stellar-sdk/).\n\nYou can also refer to:\n\n * the [documentation](https://developers.stellar.org/docs/data/horizon) for the Horizon REST API (if using the `Horizon` module) and\n * the [documentation](https://developers.stellar.org/docs/data/rpc) for Soroban RPC's API (if using the `rpc` module)\n\n### Usage with React-Native\n\n1. Install `yarn add --dev rn-nodeify`\n2. Add the following postinstall script:\n```\nyarn rn-nodeify --install url,events,https,http,util,stream,crypto,vm,buffer --hack --yarn\n```\n3. Uncomment `require('crypto')` on shim.js\n4. `react-native link react-native-randombytes`\n5. Create file `rn-cli.config.js`\n```\nmodule.exports = {\n  resolver: {\n    extraNodeModules: require(\"node-libs-react-native\"),\n  },\n};\n```\n6. Add `import \"./shim\";` to the top of `index.js`\n7. `yarn add @stellar/stellar-sdk`\n\nThere is also a [sample](https://github.com/fnando/rn-stellar-sdk-sample) that you can follow.\n\n**Note**: Only the V8 compiler (on Android) and JSC (on iOS) have proper support for `Buffer` and `Uint8Array` as is needed by this library. Otherwise, you may see bizarre errors when doing XDR encoding/decoding such as `source not specified`.\n\n#### Usage with Expo managed workflows\n\n1. Install `yarn add --dev rn-nodeify`\n2. Add the following postinstall script:\n```\nyarn rn-nodeify --install process,url,events,https,http,util,stream,crypto,vm,buffer --hack --yarn\n```\n3. Add `import \"./shim\";` to your app's entry point (by default `./App.js`)\n4. `yarn add @stellar/stellar-sdk`\n5. `expo install expo-random`\n\nAt this point, the Stellar SDK will work, except that `StellarSdk.Keypair.random()` will throw an error. To work around this, you can create your own method to generate a random keypair like this:\n\n```javascript\nimport * as Random from 'expo-random';\nimport { Keypair } from '@stellar/stellar-sdk';\n\nconst generateRandomKeypair = () =\u003e {\n  const randomBytes = Random.getRandomBytes(32);\n  return Keypair.fromRawEd25519Seed(Buffer.from(randomBytes));\n};\n```\n\n#### Usage with CloudFlare Workers\n\nBoth `eventsource` (needed for streaming) and `axios` (needed for making HTTP requests) are problematic dependencies in the CFW environment. The experimental branch [`make-eventsource-optional`](https://github.com/stellar/js-stellar-sdk/pull/901) is an attempt to resolve these issues.\n\nIt requires the following additional tweaks to your project:\n * the `axios-fetch-adapter` lets you use `axios` with `fetch` as a backend, which is available to CF workers\n * it only works with `axios@\"\u003c= 1.0.0\"` versions, so we need to force an override into the underlying dependency\n * and this can be problematic with newer `yarn` versions, so we need to force the environment to use Yarn 1\n\nIn summary, the `package.json` tweaks look something like this:\n\n```jsonc\n\"dependencies\": {\n  // ...\n  \"@stellar/stellar-sdk\": \"git+https://github.com/stellar/js-stellar-sdk#make-eventsource-optional\",\n  \"@vespaiach/axios-fetch-adapter\": \"^0.3.1\",\n  \"axios\": \"^0.26.1\"\n},\n\"overrides\": {\n  \"@stellar/stellar-sdk\": {\n    \"axios\": \"$axios\"\n  }\n},\n\"packageManager\": \"yarn@1.22.19\"\n```\n\nThen, you need to override the adapter in your codebase:\n\n```typescript\nimport { Horizon } from '@stellar/stellar-sdk';\nimport fetchAdapter from '@vespaiach/axios-fetch-adapter';\n\nHorizon.AxiosClient.defaults.adapter = fetchAdapter as any;\n\n// then, the rest of your code...\n```\n\nAll HTTP calls will use `fetch`, now, meaning it should work in the CloudFlare Worker environment.\n\n## Developing\n\nSo you want to contribute to the library: welcome! Whether you're working on a fork or want to make an upstream request, the dev-test loop is pretty straightforward.\n\n1. Clone the repo:\n\n```shell\ngit clone https://github.com/stellar/js-stellar-sdk.git\n```\n\n2. Install dependencies inside js-stellar-sdk folder:\n\n```shell\ncd js-stellar-sdk\nyarn\n```\n\n3. Install Node 18\n\nBecause we support the oldest maintenance version of Node, please install and develop on Node 18 so you don't get surprised when your code works locally but breaks in CI.\n\nHere's how to install `nvm` if you haven't: https://github.com/creationix/nvm\n\n```shell\nnvm install 18\n\n# if you've never installed 18 before you'll want to re-install yarn\nnpm install -g yarn\n```\n\nIf you work on several projects that use different Node versions, you might it helpful to install this automatic version manager: https://github.com/wbyoung/avn\n\n4. Observe the project's code style\n\nWhile you're making changes, make sure to run the linter to catch any linting\nerrors (in addition to making sure your text editor supports ESLint) and conform to the project's code style.\n\n```shell\nyarn fmt\n```\n\n### Building\nYou can build the developer version (unoptimized, commented, with source maps, etc.) or the production bundles:\n\n```shell\nyarn build\n# or\nyarn build:prod\n```\n\n### Testing\n\nTo run all tests:\n\n```shell\nyarn test\n```\n\nTo run a specific set of tests:\n\n```shell\nyarn test:node\nyarn test:browser\nyarn test:integration\n```\n\nIn order to have a faster test loop, these suite-specific commands **do not** build the bundles first (unlike `yarn test`). If you make code changes, you will need to run `yarn build` (or a subset like `yarn build:node` corresponding to the test suite) before running the tests again to see your changes.\n\nTo generate and check the documentation site:\n\n```shell\n# install the `serve` command if you don't have it already\nnpm i -g serve\n\n# clone the base library for complete docs\ngit clone https://github.com/stellar/js-stellar-base\n\n# generate the docs files\nyarn docs\n\n# get these files working in a browser\ncd jsdoc \u0026\u0026 serve .\n\n# you'll be able to browse the docs at http://localhost:5000\n```\n\n### Publishing\n\nFor information on how to contribute or publish new versions of this software to `npm`, please refer to our [contribution guide](https://github.com/stellar/js-stellar-sdk/blob/master/CONTRIBUTING.md).\n\n## Miscellaneous\n\n### `stellar-sdk` vs `stellar-base`\n\n`stellar-sdk` is a high-level library that serves as client-side API for Horizon and Soroban RPC, while [`stellar-base](https://github.com/stellar/js-stellar-base) is lower-level library for creating Stellar primitive constructs via XDR helpers and wrappers.\n\n**Most people will want stellar-sdk instead of stellar-base.** You should only use stellar-base if you know what you're doing!\n\nIf you add `stellar-sdk` to a project, **do not add `stellar-base`!** Mismatching versions could cause weird, hard-to-find bugs. `stellar-sdk` automatically installs `stellar-base` and exposes all of its exports in case you need them.\n\n\u003e **Important!** The Node.js version of the `stellar-base` (`stellar-sdk` dependency) package uses the [`sodium-native`](https://www.npmjs.com/package/sodium-native) package as an [optional dependency](https://docs.npmjs.com/files/package.json#optionaldependencies). `sodium-native` is a low level binding to [libsodium](https://github.com/jedisct1/libsodium), (an implementation of [Ed25519](https://ed25519.cr.yp.to/) signatures).\n\u003e If installation of `sodium-native` fails, or it is unavailable, `stellar-base` (and `stellar-sdk`) will fallback to using the [`tweetnacl`](https://www.npmjs.com/package/tweetnacl) package implementation. If you are using them in a browser, you can ignore this. However, for production backend deployments, you should be using `sodium-native`.\n\u003e If `sodium-native` is successfully installed and working the `StellarSdk.FastSigning` variable will return `true`.\n\n### License\n\njs-stellar-sdk is licensed under an Apache-2.0 license. See the\n[LICENSE](https://github.com/stellar/js-stellar-sdk/blob/master/LICENSE) file\nfor details.\n","funding_links":[],"categories":["JavaScript","Development","Uncategorized","TypeScript","Cryptocurrencies"],"sub_categories":["Code","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstellar%2Fjs-stellar-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstellar%2Fjs-stellar-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstellar%2Fjs-stellar-sdk/lists"}