TypeScript/JavaScript SDK for interacting with Mina Protocol nodes via GraphQL. Companion to mina-sdk-python, mina-sdk-go, and mina-sdk-rust.
- Daemon GraphQL client — query node status, accounts, blocks; send payments and delegations
- Typed response objects with a
Currencytype backed bybigint - Automatic retry with configurable backoff
- Public
executeQuery()for custom GraphQL queries - Ships ESM + CJS; works on Node 18+
npm install mina-sdkimport { Currency, MinaClient } from 'mina-sdk';
const client = new MinaClient();
console.log(await client.getSyncStatus()); // "SYNCED"
const account = await client.getAccount('B62q...');
console.log(`Balance: ${account.balance.total} MINA`);
const result = await client.sendPayment({
sender: 'B62qsender...',
receiver: 'B62qreceiver...',
amount: Currency.fromMina('1.5'),
fee: Currency.fromMina('0.01'),
});
console.log(`Tx hash: ${result.hash}`);import { MinaClient } from 'mina-sdk';
const client = new MinaClient({
graphqlUri: 'http://127.0.0.1:3085/graphql', // default
retries: 3, // must be >= 1
retryDelayMs: 5000, // delay between retries
timeoutMs: 30_000, // per-request HTTP timeout
});Constructor options are validated eagerly — invalid values throw RangeError at construction time.
| Method | Returns | Description |
|---|---|---|
getSyncStatus() |
string |
Node sync status (SYNCED, BOOTSTRAP, etc.) |
getDaemonStatus() |
DaemonStatus |
Comprehensive daemon status |
getNetworkId() |
string |
Network identifier |
getAccount(publicKey, tokenId?) |
AccountData |
Account balance, nonce, delegate |
getBestChain(maxLength?) |
BlockInfo[] |
Recent blocks from the best chain |
getPeers() |
PeerInfo[] |
Connected peers |
getPooledUserCommands(publicKey?) |
PooledUserCommand[] |
Pending transactions |
executeQuery(query, variables, name) |
T |
Run a custom GraphQL query |
| Method | Returns | Description |
|---|---|---|
sendPayment(params) |
SendPaymentResult |
Send a payment |
sendDelegation(params) |
SendDelegationResult |
Delegate stake |
setSnarkWorker(publicKey?) |
string | null |
Set/unset SNARK worker |
setSnarkWorkFee(fee) |
string |
Set SNARK work fee |
import { Currency } from 'mina-sdk';
const a = Currency.fromMina(10); // 10 MINA
const b = Currency.fromMina('1.5'); // 1.5 MINA
const c = Currency.fromNanomina(1_000_000_000n); // 1 MINA
console.log(a.add(b).toString()); // "11.500000000"
console.log(a.nanomina); // 10000000000n
console.log(a.greaterThan(b)); // true
console.log(b.mul(3).toString()); // "4.500000000"Currency is immutable and stored as a bigint of nanomina, so all arithmetic is exact.
GraphQLError— daemon returned anerrorsarray (not retried)DaemonConnectionError— transport-level failure afterretriesattemptsAccountNotFoundError—getAccountreturned anullaccountCurrencyParseError— invalid input to aCurrency.from*factoryCurrencyUnderflowError—Currency.subwould go negative
const data = await client.executeQuery<{ bestChain: Array<{ stateHash: string }> }>(
`query { bestChain(maxLength: 1) { stateHash } }`,
{},
'best_chain_head',
);
console.log(data.bestChain[0].stateHash);Apache-2.0