---
title: "@minter-network/tx-core reference"
description: "Module reference for @minter-network/tx-core: 10^18 pip integer arithmetic, canonical RLP, BIP-39/44 wallets, SecretLeakGuard, 37 transaction builders, checks, and MinterGateClient."
track: "developers"
lang: "en"
protocol: "Minter v3.3.0"
consensus: "Tendermint v0.34.19 + IAVL v0.17.3"
canonical_url: "https://docs.minter.network/developers/tx-core-sdk"
raw_markdown_url: "https://docs.minter.network/developers/tx-core-sdk.md"
---

# @minter-network/tx-core reference

> Module reference for @minter-network/tx-core: 10^18 pip integer arithmetic, canonical RLP, BIP-39/44 wallets, SecretLeakGuard, 37 transaction builders, checks, and MinterGateClient.

`@minter-network/tx-core` implements `secp256k1` cryptography, canonical RLP serialization, `10^18 pip` integer arithmetic, and a Node Gate API v2 HTTP client on native `BigInt`, `Uint8Array`, `DataView`, `TextEncoder`, and `fetch`.

Install the published package with `npm install @minter-network/tx-core`. [Package on npm](https://www.npmjs.com/package/@minter-network/tx-core)

## Runtime support

The package requires Node.js 20.19.0 or later. The runtime check signs and decodes the same `Send` test vector in each of these environments.

| Runtime | Verified versions |
| :--- | :--- |
| Node.js | 20.19.0, 22.23.5, 24.22.3 |
| Bun | 1.4.4 |
| Deno | 2.9.6 |
| Chromium | 159.0.8154.6 |

## Package modules

| Module | Underlying dependencies | Scope and key exports |
| :--- | :--- | :--- |
| `pip` | Native `BigInt` | `PIP_SCALE` (`10n ** 18n`), `parsePip`, `formatPip`, `divRoundBigInt`, `ROUNDING`, `estimateAmmOutPip`, and `estimatePairV2SwapOutPip` |
| `bytes` | Native `Uint8Array` | Hex/UTF-8 converters, strict `Mx...`, `Mp...`, `Mt...`, `Mc...` formatters, and `[10]byte` ticker encoders (`encodeTicker10`) |
| `rlp` | Built-in codec | Canonical `rlpEncode` / `rlpDecode`. `rlpDecode` rejects trailing bytes. `decodeRlpUint` rejects leading `0x00` in unsigned integers. |
| `wallet` | `@scure/bip39`, `@scure/bip32`, `@noble/hashes` | Mnemonic generation, `m/44'/60'/0'/0/{index}` derivation (`deriveWalletFromMnemonic`), `deriveMultisigAddress`, and `SecretLeakGuard` |
| `tx` and `tx-types` | `@noble/curves/secp256k1`, `@noble/hashes` | `TX_TYPE` registry, 48 `DEFAULT_V330_COMMISSION_TARIFFS` fields, builders for all 37 active opcodes, `signTx`, `signTxForMultisig`, `assembleMultisigTx`, `decodeRawTx` |
| `check` | `@noble/curves/secp256k1`, `@noble/hashes` | Off-chain `Mc...` check issuance and proof generation (`issueCheck`, `decodeCheck`, `createCheckProof`, `verifyCheckProof`) |
| `gate-client` and `verify-transfer` | Native `fetch` | `MinterGateClient` (`getStatus`, `getAddress`, `getNextNonce`, `getCoinInfo`, `getCoinInfoById`, `estimateTxCommission`, `sendTransaction`, `getTransaction`, `waitForTransaction`) and `verifyIncomingTransfer` |

Public TypeScript declarations (`dist/index.d.ts`) ship inside `@minter-network/tx-core`.

## `10^18 pip` precision and rounding (`pip`)

Balances, pool reserves, order volumes, and fee tariffs in Minter `v3.3.0` are unsigned integers denominated in atomic `pip` (`1 coin = 1_000_000_000_000_000_000 pip = 10^18 pip`). JavaScript `Number` (`float64`, `53` bits of significand, `Number.MAX_SAFE_INTEGER < 0.0091` coins in `pip`) truncates low-order digits and causes `Insufficient funds` or `non-canonical integer` rejections.

Client interfaces distinguish three numeric states:
1. Unpriced or missing data (`null` or `undefined`) renders as a placeholder (`-` or `N/A`), not zero.
2. Mathematical zero (`0n`) renders as `0.00` or `$0.00`.
3. Non-zero dust (`1n` below the display unit) renders as `< 0.0001` or `< $0.01` while keeping the exact 18-decimal `pip` string in a tooltip attribute.

| Calculation or field | `ROUNDING` mode | Protocol rationale |
| :--- | :---: | :--- |
| Spendable balance and full-balance transfer | `FLOOR` | Prevents overstating balance by `1 pip` (`Insufficient funds`) |
| Swap `minimumValueToBuy` (`0x02`, `0x17`) | `FLOOR` | Keeps minimum output at or below integer pool output after slippage |
| Swap `maximumValueToSell` (`0x04`, `0x18`) | `CEIL` | Covers integer pool input required for an exact-output swap |
| Linear `USD-pip -> gasCoin` fee estimate | `CEIL` | Prevents `1 pip` fee shortfalls during tariff conversion |
| Orderbook level aggregation | `CEIL` (Asks) / `FLOOR` (Bids) | Prevents aggregated bid and ask levels from visually crossing |
| Informational fiat display estimates | `HALF_UP` | Symmetric rounding for display-only summaries |

`parsePip` accepts a decimal string using `"."` (underscore digit separators `"_"` are accepted; commas `","` throw `SyntaxError`). Fractional parts exceeding `18` digits throw `RangeError` unless `rounding` is explicitly specified.

```typescript
import {
  ROUNDING,
  divRoundBigInt,
  estimateAmmOutPip,
  estimatePairV2SwapOutPip,
  formatPip,
  parsePip,
} from "@minter-network/tx-core";

const sendPip = parsePip("1250.50"); // 1250500000000000000000n
const label = formatPip(sendPip, {
  decimals: 2,
  trimTrailingZeros: false,
  groupThousands: true,
  rounding: ROUNDING.FLOOR,
}); // "1,250.50"

const pureAmmOutPip = estimateAmmOutPip(
  360_800_059_585_227_604_406n,
  3_986_063_084_606_142_908_469_809n,
  parsePip("100"),
);

const pairV2OutPip = estimatePairV2SwapOutPip(
  360_800_059_585_227_604_406n,
  3_986_063_084_606_142_908_469_809n,
  parsePip("100"),
);

const minBuyPip = divRoundBigInt(pairV2OutPip * 995n, 1000n, ROUNDING.FLOOR);
```

## Transaction builders and envelope (`tx`)

The `tx` module exports generic `buildTx(type, data, options)`, flat and two-argument typed builders (`buildSendTx`, `buildSellSwapPoolTx`, `buildCreateTokenTx`, `buildCreateMultisigTx`, `buildRedeemCheckTx`, and builders for the remaining active types, 37 in total), plus low-level `encodeTxData` / `decodeTxData` codecs (including data-only RLP helpers for inactive `0x13 PRICE_VOTE`, empty list `0xc0` for `0x25 LOCK_STAKE`, and `uint32` `dueBlock` for `0x26 LOCK`).

Outer envelope fields in `TxEnvelopeOptions`:
1. `nonce` (`bigint | number`): sequential account counter `transaction_count + 1n` (`uint64`).
2. `chainId` (`1 | 2`): `1` for Mainnet, `2` for Testnet.
3. `gasPrice` (`number`): gas price multiplier (`uint32`, defaults to `1`; `RedeemCheck` requires `1`).
4. `gasCoin` (`number`): numeric fee coin ID (`uint32`, `0` = `BIP` encodes as RLP `0x80`).
5. `payload` (`string | Uint8Array`): optional UTF-8 or binary memo up to `10_000` bytes (`+$0.0002` per byte).
6. `serviceData` (`string | Uint8Array`): optional arbitrary metadata up to `128` bytes (charged per byte on the same schedule as `payload`).
7. `signatureType` (`1 | 2`): `1` for single signature (`Single`), `2` for weighted multisig (`Multisig`).

Byte-level 10-field RLP rules and cross-language porting examples are covered in [Test vectors and porting](https://docs.minter.network/developers/test-vectors-and-porting); full opcode schemas are listed in [Transaction registry (`0x01..0x26`)](https://docs.minter.network/protocol/transactions-registry).

#### TypeScript (@minter-network/tx-core)

```typescript
import {
  SecretLeakGuard,
  TX_TYPE,
  buildSellSwapPoolTx,
  decodeRawTx,
  parsePip,
  signTx,
} from "@minter-network/tx-core";

// Supply these inputs from your application.
declare const privateKeyBytes: Uint8Array;

const userMemo = "swap:arb-cycle-42";
SecretLeakGuard.assertSafePublicText(userMemo);

// 2-pool swap route: USDTE (1993) -> BIP (0) -> HUB (1902).
// Base 2-pool fee $0.035 + 17 payload bytes ($0.0034) = $0.0384 in USDTE equivalent.
const unsigned = buildSellSwapPoolTx(
  {
    coins: [1993, 0, 1902],
    valueToSellPip: parsePip("250"),
    minimumValueToBuyPip: parsePip("13.45"),
  },
  {
    nonce: 42n,
    chainId: 1,
    gasPrice: 1,
    gasCoin: 1993,
    payload: userMemo,
    serviceData: new Uint8Array(0),
  },
);

const signed = signTx(unsigned, privateKeyBytes);
const decoded = decodeRawTx(signed.signedRawTxBytes);
console.log(decoded.type === TX_TYPE.SELL_SWAP_POOL, decoded.sender, signed.txHash);
```

#### cURL

For extended methods, set `MINTER_NODE_V2_URL` to the base `/v2` URL of your own node.

```bash
GATE_URL="${MINTER_GATE_URL:-https://gate.minter.network/v2}"

# Quote 2-pool route USDTE (1993) -> BIP (0) -> HUB (1902)
curl -sS "${MINTER_NODE_V2_URL:?Set the base /v2 URL of your own node}/estimate_coin_sell?coin_id_to_sell=1993&coin_id_to_buy=1902&value_to_sell=250000000000000000000&swap_from=pool&route=0"
```

## Keys, buffer wiping and `SecretLeakGuard` (`wallet`)

`deriveWalletFromMnemonic(mnemonic, accountIndex, passphrase)` derives keys along `m/44'/60'/0'/0/{accountIndex}` and wipes intermediate BIP-39 seed buffers. Zeroize `wallet.privateKey.fill(0)` in a `finally` block after signing (JavaScript strings such as `privateKeyHex` are immutable in memory, so pass `Uint8Array` keys in security-sensitive workers).

`SecretLeakGuard` (`SecretLeakGuard.inspect` and `SecretLeakGuard.assertSafePublicText`) scans public `payload` and memo inputs before broadcast and rejects the input when it detects:
1. A sequence of `>= 12` consecutive valid English BIP-39 mnemonic words (avoiding false positives on ordinary 2-to-3-word phrases).
2. A bare or `0x`-prefixed 64-character hexadecimal private key, excluding public `Mp...` and `Mt...` identifiers.
3. An unredeemed `Mc...` check string.

## `MinterGateClient` and transfer verification (`gate-client`)

`MinterGateClient` wraps Node Gate API v2 reads and transaction broadcast with `AbortController` timeouts and typed `MinterGateError` exceptions:
1. `getStatus()`, `getAddress(address, delegated?)`, and `getNextNonce(address)` read node status, account state, and the next account `nonce`. `getCoinInfo(symbol, height?)` and `getCoinInfoById(id, height?)` look up coin metadata.
2. `estimateTxCommission(signedTx)` calls `GET /v2/estimate_tx_commission/{0x...}` (near the `10_000`-byte `payload` cap, the hex URL reaches ~20 KB and can exceed reverse-proxy URL limits with `HTTP 414`).
3. `sendTransaction(signedTx)` submits `POST /v2/send_transaction` and returns mempool `CheckTx` admission.
4. `getTransaction(hash)` reads `GET /v2/transaction/{hash}`. `waitForTransaction(hash, { timeoutMs, pollMs })` polls until block inclusion, including after HTTP `404` and `400` not-found responses, and checks the execution code by default.
5. `verifyIncomingTransfer` validates a committed `Send (0x01)` with execution code `"0"` or `0`, positive block height, case-insensitive recipient match, numeric `coinId`, minimum `pip` value, expected `payload` memo, and replay deduplication against a `Set` of consumed `Mt...` hashes.

```typescript
import {
  MinterGateClient,
  parsePip,
  verifyIncomingTransfer,
} from "@minter-network/tx-core";
import type { MtHash } from "@minter-network/tx-core";

// Supply these inputs from your application.
declare const txHash: MtHash;

const gate = new MinterGateClient(
  process.env.MINTER_GATE_URL ?? "https://gate.minter.network/v2",
);
const processedTxHashes = new Set<string>();

const committedTx = await gate.waitForTransaction(txHash, {
  timeoutMs: 15_000,
  pollMs: 1_000,
});

const verification = verifyIncomingTransfer(committedTx, {
  merchantAddress: "Mx3a7b9104e82d19c64f01b5a8e9c72104d3e811f0",
  expectedCoinId: 1993,
  minAmountPip: parsePip("25.50"),
  expectedPayload: "order:INV-2026-8841",
  processedTxHashes,
});
```
