Build with CoinStats’ all-in-one API. Learn more

EnglishDeutsch한국어日本語中文EspañolFrançaisՀայերենNederlandsItalianoPortuguêsTürkçeТрекер портфеляОбменятьКриптовалютыЦеныCrypto APIИнтеграцииНовостиЗаработатьБлогNFTВиджетыТрекер DeFi ПортфеляКрипто-гейминг24ч. ОтчетПресс-китДок. API
CoinStats

Meet adamant-api 3.0 — a modern SDK for the modern ADAMANT node

2д назад
повышающийся:

0

снижающийся:

0

The JavaScript/TypeScript SDK for ADAMANT just had its biggest release yet, landing in lockstep with ADAMANT Node v0.10.0. Here’s what changed, what broke, and how to build something cool with it in five minutes.

adamant-api on npmjs

If you’ve ever wanted to build on top of a truly decentralized, anonymous messenger and blockchain — a Telegram-style bot that can’t be shut down, a tip jar that settles on-chain, a wallet that watches multiple accounts at once — adamant-api is the fastest way to get there. And as of v3.0.0, it's faster, safer, and more modular than ever.

This release is special because it ships together with ADAMANT Node v0.10.0. The SDK and the network now speak exactly the same language: millisecond timestamps, richer query parameters, a consolidated node-status response, and inclusive minimum-version filtering are all supported out of the box.

TL;DR: npm install adamant-api, point it at a few nodes, and you get automatic health checks, retries, failover, typed responses, encrypted messaging, and real-time WebSocket subscriptions. Published to npm with build provenance — Built and signed on GitHub Actions.

Why ADAMANT, why now

ADAMANT is a blockchain-based, end-to-end encrypted messenger with a built-in crypto wallet. No phone number, no email, no central server that can read your messages or freeze your account. For developers, that means you can build apps and bots where the user owns their identity and their funds, and your backend never has to hold either.

adamant-api is the official SDK that turns that network into a handful of clean function calls. v3.0.0 is a ground-up modernization of that SDK.

What’s new in 3.0

🟢 Built for ADAMANT Node v0.10.0

  • API DTOs are regenerated from a pinned adamant-schema revision — millisecond timestamps, loader/status data, numeric counts, and nullable unconfirmed-transaction fields are all typed correctly.
  • New query power: returnUnconfirmed, includeDirectTransfers, delegate lookup by address, and multi-type transaction queries.
  • Transaction filters now combine with logical and by default, and amount filters apply only to transfer transactions.
  • Optional timestampMs construction and getEpochTimeMs() — and crucially, timestampMs is not part of the signed bytes, so hashes, IDs, and signatures are unchanged.

🟢 Rock-solid reliability

  • The client stops retrying explicitly rejected POSTs and returns a structured, non-retryable error instead of looping forever.
  • Retry and active-node failover are preserved for safe requests and genuine network failures.
  • Height-aware node selection plus inclusive minVersion filtering keep you talking to healthy, up-to-date nodes.

🟢 A real WebSocket client

  • Subscribe to multiple addresses, multiple transaction types, and multiple chat asset types with a single connection.
  • Typed connection errors, connection/reconnection callbacks, explicit connect()/disconnect(), listener cleanup, and bounded reconnection.

🟢 Modular by design

  • The package root stays ADM-focused and never pulls in coin-specific code you don’t use.
  • Subpath exports for ADM, API DTOs, transactions, metadata, and BTC/ETH/DASH/DOGE helpers — both CommonJS and ESM.
  • Deterministic, reproducible coin metadata pinned from adamant-wallets.

🟢 Docs you’ll actually read

The old Wiki-first docs are gone. There’s now a source-controlled VitePress + TypeDoc site at js.docs.adamant.im with guides and a full generated API reference.

New js.docs.adamant.im website

Five-minute quick start

npm install adamant-api
import {AdamantApi} from 'adamant-api';

const api = new AdamantApi({
nodes: [
'https://endless.adamant.im',
'https://clown.adamant.im',
'https://lake.adamant.im',
],
checkHealthAtStartup: true,
minVersion: '0.10.0', // inclusive — older nodes are excluded automatically
});

api.onReady(async () => {
const response = await api.getBlocks();
if (response.success) {
console.log(response.blocks);
} else {
console.error(response.errorMessage);
}
});

That’s it. Health checks, retries, and failover across those three nodes are handled for you.

Build something cool

1. A decentralized chat bot 🤖

Watch one (or many) accounts in real time and respond to encrypted messages. This is the pattern behind support bots, alert bots, and games that live entirely on ADAMANT.

import {AdamantApi, WebSocketClient, decodeMessage} from 'adamant-api';
import {config} from './config.js';

const api = new AdamantApi({nodes: config.nodes});

const ws = new WebSocketClient({
admAddress: config.address,
direction: 'incoming', // only messages sent *to* the bot
});
api.initSocket(ws);

ws.onMessage(async (tx) => {
const text = decodeMessage(
tx.asset.chat.message,
tx.senderPublicKey,
config.passphrase,
tx.asset.chat.own_message,
);

if (text.trim() === '/ping') {
await api.sendMessage(config.passphrase, tx.senderId, 'pong 🏓');
}
});

End-to-end encryption is built in — the bot decrypts with its own passphrase, and your server never stores plaintext.

2. A crypto tip jar / payment bot 💸

React to incoming token transfers and send tokens back. Perfect for tipping bots, faucets, paywalls, or vending machines.

ws.onTransfer(async (tx) => {
const amountADM = tx.amount / 1e8;
console.log(`Received ${amountADM} ADM from ${tx.senderId}`);

// Send a thank-you transfer (amount in ADM)
await api.sendTokens(config.passphrase, tx.senderId, 0.001, true);

// ...and a receipt as a chat message
await api.sendMessage(
config.passphrase,
tx.senderId,
`Thanks! Received ${amountADM} ADM ✅`,
);
});

3. A multi-account portfolio watcher 📊

A single WebSocket connection can now watch many addresses and filter by type — ideal for exchange ingest, accounting dashboards, or a “family wallet” view.

import {WebSocketClient, TransactionType, MessageType} from 'adamant-api';

const ws = new WebSocketClient({
admAddresses: ['U1234567890', 'U0987654321', 'U5555555555'],
types: [TransactionType.SEND, TransactionType.CHAT_MESSAGE],
assetChatTypes: [MessageType.Chat, MessageType.Rich],
direction: 'allDirections', // see *everything* these accounts do
});

ws.onConnection((node) => console.log(`Live on ${node}`));
ws.onTransfer((tx) => ingest(tx));
ws.on(TransactionType.CHAT_MESSAGE, (tx) => index(tx));

4. A lightweight multi-coin wallet 🔑

Need a BTC, ETH, DASH, or DOGE address derived from the same ADAMANT passphrase — without bundling four crypto stacks into your ADM-only bot? Import exactly what you need:

import {eth} from 'adamant-api/coins/eth';
import {btc} from 'adamant-api/coins/btc';

const {address: ethAddress} = eth.keys(process.env.PASSPHRASE);
const {address: btcAddress} = btc.keys(process.env.PASSPHRASE);

console.log({ethAddress, btcAddress});

The package root never loads coin code, so your serverless bundle stays small and your cold starts stay fast.

5. A resilient backend service 🛡️

For production services, lean on the built-in reliability instead of writing your own retry loop:

const api = new AdamantApi({
nodes: config.nodes,
checkHealthAtStartup: true,
minVersion: '0.10.0',
});

const res = await api.getTransactions({
and: {type: 3, senderId: 'U1234567890'},
returnUnconfirmed: 1,
});

if (!res.success) {
// Structured, non-retryable failures surface here instead of looping forever
logger.warn(res.errorMessage);
}

Migrating from 2.x

  1. Bump Node to 22+ in your runtime and CI.
  2. Audit WebSocket direction. If your app assumed incoming-only, add direction: 'incoming'.
  3. Update coin imports to adamant-api/coins/*.
  4. Drop Lisk/Klayr code paths.
  5. Re-check your query filters for the new logical-and default, and swap withoutDirectTransfers for includeDirectTransfers.

Your signing, transaction IDs, and CommonJS/ESM imports keep working untouched.

Get started

Build something nobody can shut down. We can’t wait to see what you make. 🚀


Meet adamant-api 3.0 — a modern SDK for the modern ADAMANT node was originally published in ADAMANT on Medium, where people are continuing the conversation by highlighting and responding to this story.

2д назад
повышающийся:

0

снижающийся:

0

Управляйте всей своей криптовалютой, NFT и DeFi из одного места

Безопасно подключите используемый вами портфель для начала.