Build and sign transactions for the DecentralChain blockchain.
Transaction builder, signer, and broadcaster for the DecentralChain blockchain. Provides builder functions for all transaction types, cryptographic signing with seed phrases or private keys, and broadcasting to DecentralChain nodes.
- ESM-only package
- TypeScript-first — ships declaration files
- Tree-shakeable — zero side effects
Part of the DecentralChain SDK.
npm install @decentralchain/transactionsRequires Node.js >= 24 and an ESM environment (
"type": "module").
import { transfer, broadcast } from '@decentralchain/transactions';
const seed = 'your twelve word seed phrase here';
const tx = transfer(
{
recipient: '3L...',
amount: 100000000, // 1 DCC (8 decimals)
chainId: 'L', // DCC mainnet
},
seed,
);
const result = await broadcast(tx, 'https://nodes.decentralchain.io');transfer()— Send DCC or tokensissue()— Create a new tokenreissue()— Reissue additional tokensburn()— Burn tokenslease()— Lease DCCcancelLease()— Cancel a leasemassTransfer()— Send to multiple recipientsdata()— Write data to account data storagesetScript()— Set account script (smart account)setAssetScript()— Set asset script (smart asset)invokeScript()— Call a dApp functionexchange()— DEX exchange order
import { transfer, broadcast } from '@decentralchain/transactions';
const seed = 'your seed phrase';
const signedTx = transfer(
{
amount: 1,
recipient: '3LkWnGsqMKem4WPr4N5JKgVGsGqWd6eFHxo',
},
seed,
);
await broadcast(signedTx, 'https://nodes.decentralchain.io');import { issue, broadcast } from '@decentralchain/transactions';
const seed = 'your seed phrase';
const signedTx = issue(
{
name: 'MyToken',
description: 'A test token on DecentralChain',
quantity: 1000000,
decimals: 2,
reissuable: true,
chainId: 'L',
},
seed,
);
await broadcast(signedTx, 'https://nodes.decentralchain.io');import { data, broadcast } from '@decentralchain/transactions';
const seed = 'your seed phrase';
const signedTx = data(
{
data: [
{ key: 'integerVal', type: 'integer', value: 1 },
{ key: 'booleanVal', type: 'boolean', value: true },
{ key: 'stringVal', type: 'string', value: 'hello' },
],
chainId: 'L',
},
seed,
);
await broadcast(signedTx, 'https://nodes.decentralchain.io');import { nodeInteraction } from '@decentralchain/transactions';
const nodeUrl = 'https://nodes.decentralchain.io';
// Get account balance
const balance = await nodeInteraction.balance('3L...address', nodeUrl);
// Get account data
const accountData = await nodeInteraction.accountData('3L...address', nodeUrl);
// Wait for transaction confirmation
await nodeInteraction.waitForTx(txId, { apiBase: nodeUrl });Transactions can be signed using:
- Seed phrase:
transfer({ ... }, 'your seed phrase') - Private key:
transfer({ ... }, { privateKey: 'base58EncodedPrivateKey' }) - No signing (for multi-sig):
transfer({ ... })— creates unsigned transaction
| Network | Byte | Char |
|---|---|---|
| Mainnet | 76 | L |
| Testnet | 84 | T |
@decentralchain/ts-lib-crypto— cryptographic operations@decentralchain/ts-types— shared type definitions@decentralchain/node-api-js— node REST API client@decentralchain/protobuf-serialization— protobuf encoding@decentralchain/marshall— binary serialization
Each builder accepts transaction parameters and an optional seed/private key for signing:
function transfer(paramsOrTx: ITransferParams, seed?: TSeedTypes): TransferTransaction;
function issue(paramsOrTx: IIssueParams, seed?: TSeedTypes): IssueTransaction;
function reissue(paramsOrTx: IReissueParams, seed?: TSeedTypes): ReissueTransaction;
function burn(paramsOrTx: IBurnParams, seed?: TSeedTypes): BurnTransaction;
function lease(paramsOrTx: ILeaseParams, seed?: TSeedTypes): LeaseTransaction;
function cancelLease(paramsOrTx: ICancelLeaseParams, seed?: TSeedTypes): CancelLeaseTransaction;
function massTransfer(paramsOrTx: IMassTransferParams, seed?: TSeedTypes): MassTransferTransaction;
function data(paramsOrTx: IDataParams, seed?: TSeedTypes): DataTransaction;
function setScript(paramsOrTx: ISetScriptParams, seed?: TSeedTypes): SetScriptTransaction;
function setAssetScript(
paramsOrTx: ISetAssetScriptParams,
seed?: TSeedTypes,
): SetAssetScriptTransaction;
function invokeScript(paramsOrTx: IInvokeScriptParams, seed?: TSeedTypes): InvokeScriptTransaction;
function exchange(paramsOrTx: IExchangeParams, seed?: TSeedTypes): ExchangeTransaction;function broadcast(tx: SignedTransaction, nodeUrl: string): Promise<any>;function waitForTx(txId: string, options: { apiBase: string; timeout?: number }): Promise<any>;| Command | Purpose |
|---|---|
npm run build |
Build ESM bundle via tsdown |
npm test |
Run tests via Vitest |
npm run test:watch |
Run tests in watch mode |
npm run typecheck |
Type-check with tsc --noEmit |
npm run lint |
Lint via Biome |
npm run lint:fix |
Auto-fix lint issues |
npm run format |
Format via Biome |
npm run format:check |
Check formatting |
npm run validate |
Full quality gate (CI-equivalent) |
npm run bulletproof |
Format + lint:fix + typecheck + test |
| Package | Description |
|---|---|
@decentralchain/ts-lib-crypto |
Cryptographic primitives |
@decentralchain/ts-types |
Core TypeScript type definitions |
@decentralchain/marshall |
Binary serialization/deserialization |
@decentralchain/node-api-js |
Node REST API client |
@decentralchain/protobuf-serialization |
Protocol Buffers serialization |
See CONTRIBUTING.md.
To report a vulnerability, see SECURITY.md.
MIT — Copyright (c) DecentralChain