Skip to content

Commit 9cc0731

Browse files
committed
docs: update markdown files
1 parent 18f92ef commit 9cc0731

31 files changed

+2063
-265
lines changed

packages/sdk/docs/README.md

Lines changed: 184 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,190 @@
22

33
***
44

5-
## Classes
5+
# Mintlayer Connect SDK
66

7-
- [Client](classes/Client.md)
7+
A lightweight JavaScript/TypeScript SDK to connect your dApp to the [Mintlayer](https://www.mintlayer.org/) blockchain. It allows you to build and request to sign transactions using a compatible wallet like Mojito.
88

9-
## Interfaces
9+
---
1010

11-
- [TransactionJSONRepresentation](interfaces/TransactionJSONRepresentation.md)
11+
## Features
12+
13+
* 🔐 Secure connection to Mintlayer wallets
14+
* 📦 Transaction builder for all major transaction types
15+
* 🧮 Type-safe interfaces (TypeScript support)
16+
* 🔄 UTXO-based transaction handling
17+
* 🪙 Token minting, burning, and NFT issuance
18+
19+
---
20+
21+
## Installation
22+
23+
```bash
24+
npm install @mintlayer/sdk
25+
```
26+
27+
or with yarn:
28+
29+
```bash
30+
yarn add @mintlayer/sdk
31+
```
32+
33+
---
34+
35+
## Usage
36+
37+
### 1. Connect to wallet
38+
39+
```ts
40+
import { Client } from '@mintlayer/sdk';
41+
42+
const client = new Client();
43+
await client.connect(); // Opens wallet connection prompt
44+
```
45+
46+
---
47+
48+
### 2. Send Transfer
49+
50+
```ts
51+
await client.transfer({
52+
to: 'tmt1qxyz...', // recipient address
53+
amount: 10, // in human-readable units
54+
token_id: 'tmltk1...', // optional, omit for base coin
55+
});
56+
```
57+
58+
---
59+
60+
### 3. Build transaction manually
61+
62+
```ts
63+
const tx = await client.buildTransaction({
64+
type: 'BurnToken',
65+
params: {
66+
amount: 10,
67+
token_id: 'tmltk1...',
68+
token_details: {
69+
authority: 'tmt1q...',
70+
number_of_decimals: 8,
71+
// ... other metadata
72+
},
73+
},
74+
});
75+
```
76+
77+
---
78+
79+
### 4. Sign transaction
80+
81+
Since version 1.0.17 the SDK supports signing transactions using class Signer:
82+
83+
```ts
84+
import { Signer } from '@mintlayer/sdk';
85+
86+
const private_keys = {
87+
'tmt1qxyz...': new Uint8Array([0,0,0,...]) // Replace with actual private key bytes
88+
};
89+
90+
const signer = new Signer(private_keys);
91+
92+
const transaction = await client.buildTransaction({
93+
type: 'Transfer',
94+
params: {
95+
to: 'tmt1qxyz...', // recipient address
96+
amount: 10, // in human-readable units
97+
},
98+
});
99+
100+
const signed_transaction = await signer.signTransaction(transaction);
101+
```
102+
103+
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:
104+
105+
```ts
106+
class MyAccountProvider implements AccountProvider {
107+
async connect() {
108+
return addresses; // Replace with actual addresses
109+
}
110+
111+
async restore() {
112+
return addresses;
113+
}
114+
115+
async disconnect() {
116+
return Promise.resolve()
117+
}
118+
119+
async request(method, params) {
120+
if( method === 'signTransaction') {
121+
const signer = new Signer(private_keys);
122+
const transaction_signed = signer.sign(params.txData);
123+
124+
return Promise.resolve(transaction_signed);
125+
}
126+
throw new Error(`Method ${method} not implemented`);
127+
}
128+
}
129+
130+
const client = await Client.create({
131+
network: 'testnet',
132+
autoRestore: false,
133+
accountProvider: new MyAccountProvider()
134+
});
135+
136+
await client.connect();
137+
138+
const signed_transaction = await client.transfer({
139+
to: 'tmt1q9mfg7d6ul2nt5yhmm7l7r6wwyqkd822rymr83uc',
140+
amount: 10,
141+
});
142+
```
143+
144+
---
145+
146+
## Supported transaction types
147+
148+
* `Transfer`
149+
* `BurnToken`
150+
* `IssueFungibleToken`
151+
* `IssueNft`
152+
* `MintToken`
153+
* `UnmintToken`
154+
* `LockTokenSupply`
155+
* `ChangeMetadataUri`
156+
* `ChangeTokenAuthority`
157+
* `FreezeToken`
158+
* `UnfreezeToken`
159+
* `DataDeposit`
160+
* `CreateDelegationId`
161+
* `DelegationStake`
162+
* `DelegationWithdraw`
163+
* `CreateOrder`
164+
* `ConcludeOrder`
165+
* `FillOrder`
166+
167+
---
168+
169+
## Development & Testing
170+
171+
* Clone the repo and run `npm install`
172+
* More tests coming soon (Jest + mocks)
173+
* Contributions welcome!
174+
175+
---
176+
177+
## Security
178+
179+
All sensitive actions (signing, wallet access) require user approval via the wallet. Private keys are never exposed.
180+
181+
---
182+
183+
## License
184+
185+
MIT
186+
187+
---
188+
189+
## Need help?
190+
191+
Join the community or open an issue on [GitHub](https://github.com/mintlayer/mintlayer-connect-sdk).

0 commit comments

Comments
 (0)