{"id":38311713,"url":"https://github.com/edge/xe-utils","last_synced_at":"2026-01-17T02:32:38.763Z","repository":{"id":43887070,"uuid":"414981363","full_name":"edge/xe-utils","owner":"edge","description":"Utility library for XE blockchain API","archived":false,"fork":false,"pushed_at":"2024-02-15T11:25:07.000Z","size":174,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-28T20:12:29.956Z","etag":null,"topics":["blockchain","library","utility","xe"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2021-10-08T12:38:51.000Z","updated_at":"2024-05-02T10:04:18.000Z","dependencies_parsed_at":"2024-02-15T10:49:30.390Z","dependency_job_id":null,"html_url":"https://github.com/edge/xe-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/edge/xe-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edge%2Fxe-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edge%2Fxe-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edge%2Fxe-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edge%2Fxe-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edge","download_url":"https://codeload.github.com/edge/xe-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edge%2Fxe-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"online","status_checked_at":"2026-01-17T02:00:07.808Z","response_time":85,"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":["blockchain","library","utility","xe"],"created_at":"2026-01-17T02:32:38.579Z","updated_at":"2026-01-17T02:32:38.721Z","avatar_url":"https://github.com/edge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://cdn.edge.network/assets/img/edge-logo-green.svg\" width=\"200\"\u003e\n\n# xe-utils\n\nUtility library for XE blockchain API\n\n[![npm version](https://img.shields.io/npm/v/@edge/xe-utils)](https://www.npmjs.com/package/@edge/xe-utils) [![npm downloads](https://img.shields.io/npm/dt/@edge/xe-utils)](https://www.npmjs.com/package/@edge/xe-utils) [![license](https://img.shields.io/npm/l/@edge/xe-utils)](LICENSE.md)\n\n- [xe-utils](#xe-utils)\n  - [Usage](#usage)\n    - [On-chain variables](#on-chain-variables)\n    - [Transactions](#transactions)\n      - [Get transactions](#get-transactions)\n      - [Get pending transactions](#get-pending-transactions)\n      - [Create transactions](#create-transactions)\n    - [Stakes](#stakes)\n      - [Get stakes](#get-stakes)\n      - [Get a stake](#get-a-stake)\n    - [Wallet](#wallet)\n      - [Create a wallet](#create-a-wallet)\n      - [Recover a wallet](#recover-a-wallet)\n      - [Get wallet balance and nonce](#get-wallet-balance-and-nonce)\n      - [Validation](#validation)\n    - [Request callbacks](#request-callbacks)\n  - [License](#license)\n\n## Usage\n\nThis library provides a collection of simple functions for interacting with the XE blockchain, plus attendant features.\n\n\u003e API functions expect a `host` URL for the blockchain API to be provided as the first argument. This must be provided without a trailing slash. The standard URLs are:\n\u003e\n\u003e - Mainnet: \u003chttps://api.xe.network\u003e\n\u003e - Testnet: \u003chttps://xe1.test.network\u003e\n\u003e\n\u003e All code examples use the mainnet URL for simplicity.\n\n### On-chain variables\n\nThe XE blockchain exposes on-chain variables including staking amounts, release fee, and more. You can access these with the [core](lib/index.ts) `vars()` function:\n\n```js\nconst xe = require('@edge/xe-utils')\n\nasync function main() {\n  const vars = await xe.vars('https://api.xe.network')\n  console.log(vars)\n}\n\nmain()\n```\n\n### Transactions\n\nThe [tx](lib/tx.ts) component provides the ability to list and create transactions.\n\n#### Get transactions\n\n`tx.transactions()` gets a list of the most recent transactions, or transactions within a specific block range.\n\n```js\nconst { tx } = require('@edge/xe-utils')\n\nasync function main() {\n  let txs = await tx.transactions('https://api.xe.network')\n  console.log(txs)\n\n  txs = await tx.transactions('https://api.xe.network', { from: 159335, to: 159345 })\n  console.log(txs)\n}\n\nmain()\n```\n\n#### Get pending transactions\n\n`tx.pendingTransactions()` gets a list of pending transactions, optionally for a specific wallet address.\n\n```js\nconst { tx } = require('@edge/xe-utils')\n\nasync function main() {\n  let txs = await tx.pendingTransactions('https://api.xe.network')\n  console.log(txs)\n\n  txs = await tx.pendingTransactions('https://api.xe.network', 'xe_ed9e05C9c85Ec8c46c333111a1C19035b5ECba99')\n  console.log(txs)\n}\n\nmain()\n```\n\n#### Create transactions\n\n`tx.sign()` creates a signed transaction. `tx.createTransactions()` then submits one or more signed transactions to the blockchain.\n\n\u003e This is not a working example: you will need to substitute correct values for `my-wallet-address`, `other-wallet-address`, and `my-private-key`. See [Wallet](#wallet) for more on this.\n\n```js\nconst { tx } = require('@edge/xe-utils')\n\nasync function main() {\n  const myTx = sign({\n    timestamp: Date.now(),\n    sender: 'my-wallet-address',\n    recipient: 'other-wallet-address',\n    amount: 1e6,\n    data: { memo: 'example of sending 1 XE' },\n    nonce: 1\n  }, 'my-private-key')\n\n  const res = await tx.createTransactions('https://api.xe.network', [myTx])\n  console.log(res)\n}\n\nmain()\n```\n\n\u003e Note that the `amount` of a transaction is specified in microXE (mXE). 1 XE is 1,000,000 mXE. If dealing in XE amounts in user code, you should multiply by 1,000,000 (1e6) when preparing a transaction to get the correct `amount`.\n\n### Stakes\n\nThe [stake](lib/stake.ts) component provides access to on-chain staking information.\n\n#### Get stakes\n\n`stake.stakes()` gets a list of stakes for a specific wallet address.\n\n\u003e This is not a working example: you will need to substitute a correct value for `my-wallet-address`. See [Wallet](#wallet) for more on this.\n\n```js\nconst { stake } = require('@edge/xe-utils')\n\nasync function main() {\n  const myStakes = await stake.stakes('https://api.xe.network', 'my-wallet-address')\n  console.log(myStakes)\n}\n\nmain()\n```\n\n#### Get a stake\n\n`stake.stake()` gets a stake by its hash.\n\n\u003e This is not a working example: you will need to substitute a correct value for `my-hash`.\n\n```js\nconst { stake } = require('@edge/xe-utils')\n\nasync function main() {\n  const myStake = await stake.stake('https://api.xe.network', 'my-hash')\n  console.log(myStake)\n}\n\nmain()\n```\n\nAlternatively, `stake.stakeByTx()` gets a stake by wallet address and transaction hash. This can be useful if the stake hash is not available.\n\n\u003e This is not a working example: you will need to substitute correct values for `my-wallet-address` and `my-hash`.\n\n```js\nconst { stake } = require('@edge/xe-utils')\n\nasync function main() {\n  const myStake = await stake.stakeByTx('https://api.xe.network', 'my-wallet-address', 'my-hash')\n  console.log(myStake)\n}\n\nmain()\n```\n\n### Wallet\n\nThe [wallet](lib/wallet.ts) component provides standard XE wallet features, plus the underlying cryptographic functions for advanced usage.\n\n#### Create a wallet\n\n`wallet.create()` generates a new wallet.\n\n```js\nconst { wallet } = require('@edge/xe-utils')\n\nasync function main() {\n  const myWallet = wallet.create()\n  console.log(myWallet)\n}\n\nmain()\n```\n\n#### Recover a wallet\n\n`wallet.recover()` recovers a wallet from a private key.\n\n\u003e This is not a working example: you will need to substitute a correct value for `my-private-key`. If you do not have a private key already, you may need to [create](#create-a-wallet) one instead.\n\n```js\nconst { wallet } = require('@edge/xe-utils')\n\nasync function main() {\n  const myWallet = wallet.recover('my-private-key')\n  console.log(myWallet)\n}\n\nmain()\n```\n\n#### Get wallet balance and nonce\n\nThere are two functions for getting on-chain wallet information:\n\n- `wallet.info()` gets the current available balance and nonce\n- `wallet.infoWithNextNonce()` is slightly slower, but gets the current available balance and _next_ nonce, accounting for any pending transactions\n\n```js\nconst { wallet } = require('@edge/xe-utils')\n\nasync function main() {\n  let info = await wallet.info('https://api.xe.network', 'xe_ed9e05C9c85Ec8c46c333111a1C19035b5ECba99')\n  console.log(info)\n\n  info = await wallet.infoWithNextNonce('https://api.xe.network', 'xe_ed9e05C9c85Ec8c46c333111a1C19035b5ECba99')\n  console.log(info)\n}\n\nmain()\n```\n\n#### Validation\n\nThe functions `wallet.validateAddress()` and `wallet.validatePrivateKey()` provide a simple way to validate wallet information in user code before touching the XE blockchain.\n\n```js\nconst { wallet } = require('@edge/xe-utils')\n\nasync function main() {\n  if (!wallet.validateAddress('invalid-wallet-address')) console.error('invalid address')\n  if (!wallet.validatePrivateKey('invalid-private-key')) console.error('invalid private key')\n}\n\nmain()\n```\n\n### Request callbacks\n\nAll API wrapper functions accept a `RequestCallback` as their final argument. This can be used to control request behaviour from your own code using [SuperAgent's chaining API](https://visionmedia.github.io/superagent/).\n\nFor example, if you wanted to specify a 100ms timeout on a request for transactions, you could do:\n\n```js\nconst { tx } = require('@edge/xe-utils')\n\nasync function main() {\n  let txs = await tx.transactions('https://api.xe.network', undefined, req =\u003e req.timeout(100))\n  console.log(txs)\n}\n```\n\n\u003e Note that undefined arguments cannot be omitted, as we do not provide overloaded functions in this library. You can write your own wrapper to simplify this if you prefer.\n\n## Contributing\n\nInterested in contributing to the project? Amazing! Before you do, please have a quick look at our [Contributor Guidelines](CONTRIBUTING.md) where we've got a few tips to help you get started.\n\n## License\n\nEdge is the infrastructure of Web3. A peer-to-peer network and blockchain providing high performance decentralised web services, powered by the spare capacity all around us.\n\nCopyright notice\n(C) 2021 Edge Network Technologies Limited \u003csupport@edge.network\u003e\u003cbr /\u003e\nAll rights reserved\n\nThis product is part of Edge.\nEdge is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version (\"the GPL\").\n\n**If you wish to use Edge outside the scope of the GPL, please contact us at licensing@edge.network for details of alternative license arrangements.**\n\n**This product may be distributed alongside other components available under different licenses (which may not be GPL). See those components themselves, or the documentation accompanying them, to determine what licenses are applicable.**\n\nEdge is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nThe GNU General Public License (GPL) is available at: https://www.gnu.org/licenses/gpl-3.0.en.html\u003cbr /\u003e\nA copy can be found in the file GPL.md distributed with\nthese files.\n\nThis copyright notice MUST APPEAR in all copies of the product!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedge%2Fxe-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedge%2Fxe-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedge%2Fxe-utils/lists"}