{"_id":"@ar-packages-changeit/ergo-box-selection","_rev":"2-5463034d670e1b082b45c701af1b6678","name":"@ar-packages-changeit/ergo-box-selection","dist-tags":{"develop":"2.0.2-7bc25721","latest":"2.0.2"},"versions":{"2.0.2-7bc25721":{"name":"@ar-packages-changeit/ergo-box-selection","version":"2.0.2-7bc25721","author":{"name":"Rosen Team"},"license":"MIT","_id":"@ar-packages-changeit/ergo-box-selection@2.0.2-7bc25721","maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"homepage":"https://github.com/rosen-bridge/selection#readme","bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"dist":{"shasum":"4a1a02ce5e05be3a35aee0027046e0d4b9ac64e0","tarball":"https://registry.npmjs.org/@ar-packages-changeit/ergo-box-selection/-/ergo-box-selection-2.0.2-7bc25721.tgz","fileCount":9,"integrity":"sha512-6nXg8VZyqezXXWLfTfnFEhHlApBUvH5GDwUKA10SCpyotgpWZyTDyepSuuMdrjKYC+33DukJ6r+xCFhPWon8fA==","signatures":[{"sig":"MEUCIE+m+w9g5e9Old38rFiURY/JOcocte57t6i/QPlS8thxAiEA0q18bsTr05z3pYzs8lzLMpnzb75QNW+68NsxJYQfWvs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11742},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=22.18.0"},"gitHead":"7bc25721f554f9b4be8b1c1599b621955c6dbb6c","scripts":{"lint":"eslint --fix . && npm run prettify","test":"NODE_OPTIONS='--import tsx' vitest","build":"tsc --build tsconfig.build.json","clean":"rimraf dist && rimraf tsconfig.build.tsbuildinfo","release":"npm run clean && npm run build && npm run test -- --run && npm publish --access public","coverage":"npm run test -- --run --coverage","prettify":"prettier --write . --ignore-path ../../.gitignore","lint:check":"eslint . && npm run prettify:check","type-check":"tsc --noEmit","prettify:check":"prettier --check . --ignore-path ../../.gitignore"},"_npmUser":{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"},"repository":{"url":"git+https://github.com/rosen-bridge/selection.git","type":"git"},"_npmVersion":"11.6.2","description":"A Typescript package to select enough Ergo utxos for required amount of assets","directories":{},"_nodeVersion":"22.18.0","dependencies":{"ergo-lib-wasm-nodejs":"^0.24.1","@rosen-bridge/selection-types":"^1.0.1","@rosen-bridge/abstract-box-selection":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.5","vitest":"^3.1.4","@vitest/coverage-istanbul":"^3.1.4"},"_npmOperationalInternal":{"tmp":"tmp/ergo-box-selection_2.0.2-7bc25721_1763557932778_0.4227543865312611","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@ar-packages-changeit/ergo-box-selection","version":"2.0.2","description":"A Typescript package to select enough Ergo utxos for required amount of assets","repository":{"type":"git","url":"git+https://github.com/rosen-bridge/selection.git"},"license":"MIT","author":{"name":"Rosen Team"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc --build tsconfig.build.json","clean":"rimraf dist && rimraf tsconfig.build.tsbuildinfo","coverage":"npm run test -- --run --coverage","lint":"eslint --fix . && npm run prettify","lint:check":"eslint . && npm run prettify:check","prettify":"prettier --write . --ignore-path ../../.gitignore","prettify:check":"prettier --check . --ignore-path ../../.gitignore","release":"npm run clean && npm run build && npm run test -- --run && npm publish --access public","test":"NODE_OPTIONS='--import tsx' vitest","type-check":"tsc --noEmit"},"dependencies":{"@rosen-bridge/abstract-box-selection":"^1.0.1","@rosen-bridge/selection-types":"^1.0.1","ergo-lib-wasm-nodejs":"^0.24.1"},"devDependencies":{"@vitest/coverage-istanbul":"^3.1.4","tsx":"^4.20.5","vitest":"^3.1.4"},"engines":{"node":">=22.18.0"},"gitHead":"fc55a043c8019b3f18d0c1a033f12d43a4693458","_id":"@ar-packages-changeit/ergo-box-selection@2.0.2","bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"homepage":"https://github.com/rosen-bridge/selection#readme","_nodeVersion":"22.18.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-ScGIXEVyA16zLhyArp+i1KbcQT7m34vigkJtimhWVNS7aLDuejgZUCpXbU6N58jxKaMWqXWoRlSi0ybozx+W7g==","shasum":"c3e330da544bce50be115de87751cfb176a8d604","tarball":"https://registry.npmjs.org/@ar-packages-changeit/ergo-box-selection/-/ergo-box-selection-2.0.2.tgz","fileCount":10,"unpackedSize":65099,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFnOScCaUu5sldTNo9pMTwhMYTgAvXP5S1ReCScK6MGaAiBokHwj4yFMRwn5Pz0JQzmUiZmDJlowNoU3wasCZ8qjQw=="}]},"_npmUser":{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"},"directories":{},"maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ergo-box-selection_2.0.2_1763558449050_0.12007316777636845"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-19T13:12:12.665Z","modified":"2025-11-19T13:20:49.432Z","2.0.2-7bc25721":"2025-11-19T13:12:12.955Z","2.0.2":"2025-11-19T13:20:49.228Z"},"bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"author":{"name":"Rosen Team"},"license":"MIT","homepage":"https://github.com/rosen-bridge/selection#readme","repository":{"type":"git","url":"git+https://github.com/rosen-bridge/selection.git"},"description":"A Typescript package to select enough Ergo utxos for required amount of assets","maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"readme":"# @rosen-bridge/ergo-box-selection\n\n## Table of contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n\n## Introduction\n\nA TypeScript package for selecting Ergo boxes to cover required amounts of assets, built on top of the abstract box selection framework.\n\n## Installation\n\nnpm:\n\n```sh\nnpm i @rosen-bridge/ergo-box-selection\n```\n\nyarn:\n\n```sh\nyarn add @rosen-bridge/ergo-box-selection\n```\n\n## Usage\n\nHere's a basic example of how to use this package:\n\n```typescript\nimport { DummyLogger } from '@rosen-bridge/abstract-logger';\nimport { ErgoBoxSelection } from '@rosen-bridge/ergo-box-selection';\n\n// Create the selection instance\nconst selector = new ErgoBoxSelection(new DummyLogger());\n\n// Define required assets\nconst requiredAssets = {\n  nativeToken: 1000000000000n, // 1000 ERG\n  tokens: [\n    { id: 'token1', value: 100n },\n    { id: 'token2', value: 200n },\n  ],\n};\n\n// Define boxes\nconst boxes: ErgoBox[] = [\n  {\n    boxId: 'box1',\n    value: 5000000000000n, // 5000 ERG\n    tokens: [{ id: 'token1', value: 100n }],\n    creationHeight: 100000,\n  },\n  {\n    boxId: 'box2',\n    value: 3000000000000n, // 3000 ERG\n    tokens: [{ id: 'token2', value: 200n }],\n    creationHeight: 100001,\n  },\n];\n\n// Get covering boxes\nconst result = await selector.getCoveringBoxes(\n  requiredAssets,\n  [], // forbidden box IDs\n  new Map(), // track map\n  boxes.values(),\n);\n\nif (result.covered) {\n  console.log('Selected boxes:', result.boxes);\n  console.log('Additional assets:', result.additionalAssets);\n} else {\n  console.log('Could not cover requirements');\n}\n```\n\nYou can also use custom min box value and limit number of tokens per change box by passing them as arguments to the `getCoveringBoxes` method.\n\n```typescript\nconst result = await selector.getCoveringBoxes(\n  requiredAssets,\n  [], // forbidden box IDs\n  new Map(), // track map\n  boxes.values(),\n  2000000n, // min box value\n  3, // max token count\n);\n```\n","readmeFilename":"README.md"}