A lightweight JavaScript/TypeScript SDK to connect your dApp to the Mintlayer blockchain. It allows you to build and request to sign transactions using a compatible wallet like Mojito.
- 🔐 Secure connection to Mintlayer wallets
- 📦 Transaction builder for all major transaction types
- 🧮 Type-safe interfaces (TypeScript support)
- 🔄 UTXO-based transaction handling
- 🪙 Token minting, burning, and NFT issuance
npm install @mintlayer/sdkor with yarn:
yarn add @mintlayer/sdkimport { Client } from '@mintlayer/sdk';
const client = new Client();
await client.connect(); // Opens wallet connection promptawait client.transfer({
to: 'tmt1qxyz...', // recipient address
amount: 10, // in human-readable units
token_id: 'tmltk1...', // optional, omit for base coin
});const tx = await client.buildTransaction({
type: 'BurnToken',
params: {
amount: 10,
token_id: 'tmltk1...',
token_details: {
authority: 'tmt1q...',
number_of_decimals: 8,
// ... other metadata
},
},
});Since version 1.0.17 the SDK supports signing transactions using class Signer:
import { Signer } from '@mintlayer/sdk';
const private_keys = {
'tmt1qxyz...': new Uint8Array([0,0,0,...]) // Replace with actual private key bytes
};
const signer = new Signer(private_keys);
const transaction = await client.buildTransaction({
type: 'Transfer',
params: {
to: 'tmt1qxyz...', // recipient address
amount: 10, // in human-readable units
},
});
const signed_transaction = await signer.signTransaction(transaction);To use helper methods, you have to implement AccountProvider interface that will handle connection and signing requests. By default, SDK communicates to Mojito Account Provider. Here's an example implementation:
class MyAccountProvider implements AccountProvider {
async connect() {
return addresses; // Replace with actual addresses
}
async restore() {
return addresses;
}
async disconnect() {
return Promise.resolve()
}
async request(method, params) {
if( method === 'signTransaction') {
const signer = new Signer(private_keys);
const transaction_signed = signer.sign(params.txData);
return Promise.resolve(transaction_signed);
}
throw new Error(`Method ${method} not implemented`);
}
}
const client = await Client.create({
network: 'testnet',
autoRestore: false,
accountProvider: new MyAccountProvider()
});
await client.connect();
const signed_transaction = await client.transfer({
to: 'tmt1q9mfg7d6ul2nt5yhmm7l7r6wwyqkd822rymr83uc',
amount: 10,
});TransferBurnTokenIssueFungibleTokenIssueNftMintTokenUnmintTokenLockTokenSupplyChangeMetadataUriChangeTokenAuthorityFreezeTokenUnfreezeTokenDataDepositCreateDelegationIdDelegationStakeDelegationWithdrawCreateOrderConcludeOrderFillOrder
- Clone the repo and run
npm install - More tests coming soon (Jest + mocks)
- Contributions welcome!
All sensitive actions (signing, wallet access) require user approval via the wallet. Private keys are never exposed.
MIT
Join the community or open an issue on GitHub.