Minter Docsv3.3.0
Developers / Quickstart
Developers

Quickstart

Install @minter-network/tx-core, derive a BIP-44 Mx wallet, fund it from the public Testnet faucet (chainId 2, MNT), sign Send (0x01), and wait for block commit via MinterGateClient.

@minter-network/tx-core builds, RLP-encodes, signs, and broadcasts Minter v3.3.0 transactions through MinterGateClient using native BigInt (1 coin = 10^18 pip). Public endpoint URLs for Mainnet (chainId: 1) and Testnet (chainId: 2) are listed in API overview and network endpoints.

Installation and wallet generation

Install the package in Node.js 20.19.0+, Bun, Deno, or a browser bundler project:

bash
npm init -y
npm install @minter-network/tx-core
npm install -D tsx

Save this example as prepare.mts and run npx tsx prepare.mts. It creates two Testnet addresses and stores the mnemonic, recipient, and epoch in a local .env.testnet file with mode 0600. Keep that file private.

typescript
import { writeFileSync } from "node:fs";
import { deriveWalletFromMnemonic, generateWalletMnemonic } from "@minter-network/tx-core";

const statusResponse = await fetch("https://testnet.minter.network/status.json", {
  redirect: "error",
  cache: "no-store",
});
if (!statusResponse.ok) throw new Error("Testnet manifest is unavailable");
const status = await statusResponse.json();
if (
  status.state !== "ok" || status.public_api_ready !== true ||
  status.minter_chain_id_byte !== 2 || !/^minter-testnet-[0-9]{6}$/.test(status.chain_id)
) {
  throw new Error("Public Testnet is not ready");
}

const mnemonic = generateWalletMnemonic(128);
const wallet = deriveWalletFromMnemonic(mnemonic, 0);
const recipient = deriveWalletFromMnemonic(mnemonic, 1);
try {
  writeFileSync(".env.testnet", [
    `MINTER_MNEMONIC="${mnemonic}"`,
    `MINTER_RECIPIENT=${recipient.address}`,
    `MINTER_TESTNET_EPOCH=${status.chain_id}`,
    "",
  ].join("\n"), { encoding: "utf8", mode: 0o600, flag: "wx" });
  console.log("Testnet funding address:", wallet.address);
  console.log("Recipient:", recipient.address);
} finally {
  wallet.privateKey.fill(0);
  recipient.privateKey.fill(0);
}

Public Testnet faucet funding

Pass your Mx... address to the public Testnet faucet (https://faucet.testnet.minter.network, chainId: 2) to dispense 1,000 MNT (coinId: 0). Public Testnet endpoints (https://gate-api.testnet.minter.network/v2, https://explorer.testnet.minter.network/, and the epoch manifest https://testnet.minter.network/status.json) are isolated from Mainnet (chainId: 1).

Monthly full reset and cross-epoch replay

On the 1st of each month the public Testnet resets completely to a new monthly epoch minter-testnet-YYYYMM, wiping all balances, custom coins, pools, and transaction history while restarting account nonce counters from 0. Service keys (treasury, faucet hot wallet, generator) rotate on every epoch, whereas chainId stays 2 (0x02) across epochs: if a user reuses the same Mx... address in a later epoch and funds it again, a transaction signed in an earlier epoch can be replayed. Generate a fresh disposable test mnemonic per epoch, keep Mainnet keys separate, and check https://testnet.minter.network/status.json for the active chain_id and first_block_hash.

Public Testnet faucet (chainId = 2 · MNT)
Monthly full reset and cross-epoch replay: on the 1st of each month the public Testnet resets completely to a new epoch minter-testnet-YYYYMM (all balances, coins, pools, and history are wiped and account nonce counters restart from 0). Because chainId = 2 stays constant across monthly epochs, a transaction signed by a reused user Mx... address in an earlier epoch can be replayed if that address is funded again in a later epoch. Generate a fresh disposable test mnemonic for each epoch.
1,000 MNT (ID 0)

Signing and broadcasting Send (0x01)

After the faucet payout is confirmed, save the next example as send.mts and run npx tsx --env-file=.env.testnet send.mts. It checks the epoch, sends 25.50 MNT to the second address, and prints an Explorer link after the transaction commits. If confirmation stalls, look up the printed hash before trying again.

typescript
import {
  CHAIN_ID,
  MinterGateClient,
  buildSendTx,
  deriveWalletFromMnemonic,
  isValidMxAddress,
  parsePip,
  signTx,
} from "@minter-network/tx-core";

const { MINTER_MNEMONIC: mnemonic, MINTER_RECIPIENT: recipient, MINTER_TESTNET_EPOCH: epoch } = process.env;
if (!mnemonic?.trim() || !recipient || !isValidMxAddress(recipient) ||
    !epoch || !/^minter-testnet-[0-9]{6}$/.test(epoch)) {
  throw new Error("Load .env.testnet from the wallet setup step");
}

const noRedirect: typeof fetch = (input, init) => fetch(input, { ...init, redirect: "error" });
const gate = new MinterGateClient({
  baseUrl: "https://gate-api.testnet.minter.network/v2",
  fetchImpl: noRedirect,
});

async function checkEpoch() {
  const response = await noRedirect("https://testnet.minter.network/status.json", { cache: "no-store" });
  if (!response.ok) throw new Error("Testnet manifest is unavailable");
  const status = await response.json();
  if (status.state !== "ok" || status.public_api_ready !== true ||
      status.minter_chain_id_byte !== CHAIN_ID.TESTNET || status.chain_id !== epoch) {
    throw new Error("Testnet epoch is unavailable or changed. Prepare a new test wallet after a reset.");
  }
  const node = await gate.getStatus();
  if (node.network !== epoch || node.catching_up !== false) {
    throw new Error("The public Testnet node does not match the wallet epoch");
  }
}

await checkEpoch();
const wallet = deriveWalletFromMnemonic(mnemonic, 0);
try {
  const nonce = await gate.getNextNonce(wallet.address);
  const unsignedTx = buildSendTx(
    { coinId: 0, to: recipient, valuePip: parsePip("25.50") },
    { nonce, chainId: CHAIN_ID.TESTNET, gasPrice: 1, gasCoin: 0 },
  );
  const { signedRawTxHex, txHash } = signTx(unsignedTx, wallet.privateKey);
  await checkEpoch();
  console.log("Transaction hash:", txHash);
  const mempool = await gate.sendTransaction(signedRawTxHex);
  if (String(mempool.code) !== "0") {
    throw new Error(`CheckTx rejected (${mempool.code}): ${mempool.log}`);
  }

  const receipt = await gate.waitForTransaction(txHash);
  console.log("Committed:", receipt.hash, "height:", receipt.height, "code:", receipt.code);
  console.log("Explorer:", `https://explorer.testnet.minter.network/transactions/${receipt.hash}`);
} finally {
  wallet.privateKey.fill(0);
}
Mempool admission (CheckTx) is not block finality (DeliverTx)
A code: "0" response from POST /v2/send_transaction confirms mempool CheckTx validation only. Finality requires committed block execution (DeliverTx) with string code === "0" verified via GET /v2/transaction/{hash} or waitForTransaction. On block execution failure, FailedTx is deducted and the sender's Nonce does not increment.

Paying fees in non-BIP coins

When an account holds 0 BIP, set gasCoin to the numeric ID of a liquid coin such as 1993 (USDTE) or 1902 (HUB). The node converts the fee through the coin's BIP swap pool or CRR reserve inside the same transaction and adds 1 gas unit (the transaction is rejected if pool or reserve liquidity is insufficient). Full gas accounting rules are specified in Execution, gas and fees. When transferring the full balance of the coin selected as gasCoin, query gate.estimateTxCommission(signedRawTxHex) beforehand and leave a margin for pool price changes between estimation and block commit.