# @fleet-sdk/core

> Fleet SDK core library

Latest version **0.12.0** (published 2025-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fleet-sdk/core
pnpm add @fleet-sdk/core
yarn add @fleet-sdk/core
bun add @fleet-sdk/core
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.12.0 |
| Published | 2025-07-26 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 3 |
| Unpacked size | 433.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 39 |
| Maintainers | capt-nemo |
| Keywords | ergo, blockchain, transactions, serialization |

## Links

- npm: https://www.npmjs.com/package/@fleet-sdk/core
- Repository: https://github.com/fleet-sdk/fleet
- Homepage: https://github.com/fleet-sdk/fleet#readme
- Issues: https://github.com/fleet-sdk/fleet/issues
- npm.io page: https://npm.io/package/@fleet-sdk/core

## Dependencies (3)

- [@fleet-sdk/common](https://npm.io/package/@fleet-sdk/common.md) ^0.10.0
- [@fleet-sdk/crypto](https://npm.io/package/@fleet-sdk/crypto.md) ^0.11.0
- [@fleet-sdk/serializer](https://npm.io/package/@fleet-sdk/serializer.md) ^0.11.0

## Recent versions

- 0.12.0 (latest) — 2025-07-26
- 0.11.0 — 2025-07-17
- 0.10.0 — 2025-06-10
- 0.9.1 — 2025-05-28
- 0.9.0 — 2025-05-28
- 0.8.5 — 2025-05-14
- 0.8.3 — 2025-04-21
- 0.8.2 — 2025-01-24
- 0.8.1 — 2024-12-09
- 0.8.0 — 2024-11-26
- 0.7.0 — 2024-09-17
- 0.6.4 — 2024-09-11
- 0.6.1 — 2024-08-13
- 0.5.0 — 2024-06-21
- 0.4.1 — 2024-06-10
- … 45 more at https://npm.io/package/@fleet-sdk/core/versions

## README

# @fleet-sdk/core [![License](https://badgen.net/github/license/fleet-sdk/fleet/)](https://github.com/fleet-sdk/fleet/blob/master/LICENSE) [![npm](https://badgen.net/npm/v/@fleet-sdk/core)](https://www.npmjs.com/package/@fleet-sdk/core)

Easily write Ergo off-chain code with a lightweight and pure JS library.

- 🪄 Easy to use
- 🪶 Lightweight: [~15kB minified + gziped](https://bundlephobia.com/package/@fleet-sdk/core)
- 🦾 Powerful: easily create complex transactions with a fluent API
- 🧪 100% code coverage
- 🌲 Tree-shakeable

# Basic Usage

## Installation

```bash
npm install @fleet-sdk/core
```

## Building a simple transaction

```ts
import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j"))
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();
```

## Building a transaction with multiple outputs

To build a a transaction with multiple outputs you can simply pass an array of `OutputBuilder` as argument of `to()` method.

```ts
import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to([
    new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j"),
    new OutputBuilder(2000000n, "9fhJkRaSoPfzE9rA3e4ptK51xvyNsLKonYN1xje5LWaLukx7iX2")
  ])
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();
```

## Sending tokens

```ts
import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(
    new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j").addTokens([
      { tokenId: "0cd8c9f416e5b1ca9f986a7f10a84191dfb85941619e49e53c0dc30ebf83324b", amount: 100n },
      { tokenId: "36aba4b4a97b65be491cf9f5ca57b5408b0da8d0194f30ec8330d1e8946161c1", amount: 429n }
    ])
  )
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();
```

## Minting tokens

```ts
import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(
    new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j").mintToken({
      name: "TestToken",
      amount: 21000000n,
      decimals: 4,
      description: "Just a test token"
    })
  )
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();
```

## Burning tokens

```ts
import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .burnTokens([
    { tokenId: "0cd8c9f416e5b1ca9f986a7f10a84191dfb85941619e49e53c0dc30ebf83324b", amount: 100n },
    { tokenId: "36aba4b4a97b65be491cf9f5ca57b5408b0da8d0194f30ec8330d1e8946161c1", amount: 429n }
  ])
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();
```

## Ensuring input inclusion

You can use `configureSelector` method to ensure one or more inputs to be included in the transaction. Useful when working with contracts.

```ts
import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const boxId = "e56847ed19b3dc6b72828fcfb992fdf7310828cf291221269b7ffc72fd66706e";
const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j"))
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .configureSelector((selector) => selector.ensureInclusion((input) => input.boxId === boxId))
  .payMinFee()
  .build();
```

---
_Source: https://npm.io/package/@fleet-sdk/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
