@rougechain/sdk 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +223 -207
- package/dist/index.cjs +58 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -7
- package/dist/index.d.ts +37 -7
- package/dist/index.js +57 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,334 +1,350 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://rougechain.io">
|
|
3
|
+
<img src="https://rougechain.io/logo.webp" alt="RougeChain" width="80" height="80" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
<h1 align="center">@rougechain/sdk</h1>
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>Build quantum-safe dApps on RougeChain</strong><br />
|
|
11
|
+
Transfers · DEX · NFTs · Bridge · Mail · Messenger
|
|
12
|
+
</p>
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/package/@rougechain/sdk"><img src="https://img.shields.io/npm/v/@rougechain/sdk?color=00d2be&label=npm" alt="npm version" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@rougechain/sdk"><img src="https://img.shields.io/npm/dm/@rougechain/sdk?color=00d2be" alt="npm downloads" /></a>
|
|
17
|
+
<a href="https://github.com/cyberdreadx/quantum-vault/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license" /></a>
|
|
18
|
+
<a href="https://docs.rougechain.io"><img src="https://img.shields.io/badge/docs-rougechain-00d2be" alt="docs" /></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
The official SDK for **RougeChain** — a post-quantum Layer 1 blockchain secured by **ML-DSA-65** (CRYSTALS-Dilithium). All transaction signing happens client-side with NIST-approved post-quantum cryptography. Private keys never leave your application.
|
|
24
|
+
|
|
25
|
+
Works in the **browser**, **Node.js 18+**, and **React Native**.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
8
28
|
|
|
9
29
|
```bash
|
|
10
30
|
npm install @rougechain/sdk
|
|
11
31
|
```
|
|
12
32
|
|
|
13
|
-
##
|
|
33
|
+
## 30-Second Quickstart
|
|
14
34
|
|
|
15
35
|
```typescript
|
|
16
|
-
import { RougeChain, Wallet } from
|
|
17
|
-
|
|
18
|
-
// Connect to a RougeChain node
|
|
19
|
-
const rc = new RougeChain('https://testnet.rougechain.io/api');
|
|
36
|
+
import { RougeChain, Wallet } from "@rougechain/sdk";
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
const rc = new RougeChain("https://testnet.rougechain.io/api");
|
|
22
39
|
const wallet = Wallet.generate();
|
|
23
|
-
console.log('Public key:', wallet.publicKey);
|
|
24
40
|
|
|
25
|
-
//
|
|
41
|
+
// Get testnet tokens
|
|
26
42
|
await rc.faucet(wallet);
|
|
27
43
|
|
|
28
|
-
//
|
|
29
|
-
const balance = await rc.getBalance(wallet.publicKey);
|
|
30
|
-
console.log('Balance:', balance);
|
|
31
|
-
|
|
32
|
-
// Transfer tokens
|
|
44
|
+
// Send 100 XRGE
|
|
33
45
|
await rc.transfer(wallet, { to: recipientPubKey, amount: 100 });
|
|
46
|
+
|
|
47
|
+
// Check balance
|
|
48
|
+
const { balance } = await rc.getBalance(wallet.publicKey);
|
|
34
49
|
```
|
|
35
50
|
|
|
36
|
-
##
|
|
51
|
+
## Features
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
| Feature | Sub-client | Description |
|
|
54
|
+
|---------|-----------|-------------|
|
|
55
|
+
| **Wallet** | — | ML-DSA-65 keypair generation, import/export, client-side signing |
|
|
56
|
+
| **Transfers** | `rc` | Send XRGE or custom tokens, burn tokens |
|
|
57
|
+
| **Token Creation** | `rc` | Launch new tokens with on-chain logo support |
|
|
58
|
+
| **Staking** | `rc` | Stake/unstake XRGE for validation |
|
|
59
|
+
| **DEX** | `rc.dex` | AMM pools, swaps with slippage protection, liquidity |
|
|
60
|
+
| **NFTs** | `rc.nft` | RC-721 collections, mint, batch mint, royalties, freeze |
|
|
61
|
+
| **Bridge** | `rc.bridge` | ETH ↔ qETH, USDC ↔ qUSDC, XRGE bridge (Base Sepolia) |
|
|
62
|
+
| **Mail** | `rc.mail` | On-chain encrypted email (`@rouge.quant`) |
|
|
63
|
+
| **Messenger** | `rc.messenger` | E2E encrypted messaging with self-destruct |
|
|
39
64
|
|
|
40
|
-
|
|
65
|
+
## Wallet
|
|
41
66
|
|
|
42
67
|
```typescript
|
|
43
|
-
import { Wallet } from
|
|
68
|
+
import { Wallet } from "@rougechain/sdk";
|
|
44
69
|
|
|
45
|
-
// Generate a new
|
|
70
|
+
// Generate a new post-quantum keypair
|
|
46
71
|
const wallet = Wallet.generate();
|
|
47
72
|
|
|
48
73
|
// Restore from saved keys
|
|
49
74
|
const restored = Wallet.fromKeys(publicKey, privateKey);
|
|
50
75
|
|
|
51
|
-
// Export for storage
|
|
76
|
+
// Export for storage
|
|
52
77
|
const keys = wallet.toJSON(); // { publicKey, privateKey }
|
|
53
78
|
|
|
54
79
|
// Verify keypair integrity
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Client
|
|
59
|
-
|
|
60
|
-
The `RougeChain` client handles all API communication. Pass a wallet to any write method to sign transactions automatically.
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
import { RougeChain } from '@rougechain/sdk';
|
|
64
|
-
|
|
65
|
-
const rc = new RougeChain('https://testnet.rougechain.io/api');
|
|
66
|
-
|
|
67
|
-
// With API key (if the node requires it)
|
|
68
|
-
const rc = new RougeChain('https://testnet.rougechain.io/api', {
|
|
69
|
-
apiKey: 'your-api-key',
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Custom fetch (useful for Node.js < 18 or React Native)
|
|
73
|
-
const rc = new RougeChain('https://testnet.rougechain.io/api', {
|
|
74
|
-
fetch: customFetchFn,
|
|
75
|
-
});
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## API Reference
|
|
79
|
-
|
|
80
|
-
### Queries (no wallet needed)
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
// Node
|
|
84
|
-
const stats = await rc.getStats();
|
|
85
|
-
const health = await rc.getHealth();
|
|
86
|
-
|
|
87
|
-
// Blocks
|
|
88
|
-
const blocks = await rc.getBlocks({ limit: 10 });
|
|
89
|
-
const summary = await rc.getBlocksSummary('24h');
|
|
90
|
-
|
|
91
|
-
// Balance
|
|
92
|
-
const balance = await rc.getBalance(publicKey);
|
|
93
|
-
const tokenBal = await rc.getTokenBalance(publicKey, 'MYTOKEN');
|
|
94
|
-
|
|
95
|
-
// Tokens
|
|
96
|
-
const tokens = await rc.getTokens();
|
|
97
|
-
const meta = await rc.getTokenMetadata('MYTOKEN');
|
|
98
|
-
const holders = await rc.getTokenHolders('MYTOKEN');
|
|
99
|
-
|
|
100
|
-
// Validators
|
|
101
|
-
const validators = await rc.getValidators();
|
|
102
|
-
const finality = await rc.getFinality();
|
|
103
|
-
|
|
104
|
-
// Burned tokens
|
|
105
|
-
const burned = await rc.getBurnedTokens();
|
|
80
|
+
wallet.verify(); // true
|
|
106
81
|
```
|
|
107
82
|
|
|
108
|
-
|
|
83
|
+
## Transfers & Tokens
|
|
109
84
|
|
|
110
85
|
```typescript
|
|
111
|
-
//
|
|
86
|
+
// Send XRGE
|
|
112
87
|
await rc.transfer(wallet, { to: recipient, amount: 100 });
|
|
113
88
|
|
|
114
|
-
//
|
|
115
|
-
await rc.transfer(wallet, { to: recipient, amount: 50, token:
|
|
89
|
+
// Send custom token
|
|
90
|
+
await rc.transfer(wallet, { to: recipient, amount: 50, token: "MYTOKEN" });
|
|
116
91
|
|
|
117
|
-
// Create a new token
|
|
92
|
+
// Create a new token (costs 100 XRGE)
|
|
118
93
|
await rc.createToken(wallet, {
|
|
119
|
-
name:
|
|
120
|
-
symbol:
|
|
94
|
+
name: "My Token",
|
|
95
|
+
symbol: "MTK",
|
|
121
96
|
totalSupply: 1_000_000,
|
|
97
|
+
image: "https://example.com/logo.png", // optional — URL or data:image/webp;base64,...
|
|
122
98
|
});
|
|
123
99
|
|
|
124
|
-
//
|
|
125
|
-
await rc.
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
### Staking
|
|
100
|
+
// Update token metadata (creator only)
|
|
101
|
+
await rc.updateTokenMetadata(wallet, {
|
|
102
|
+
symbol: "MTK",
|
|
103
|
+
image: "data:image/webp;base64,UklGR...", // base64 logos persist on-chain
|
|
104
|
+
description: "A community token",
|
|
105
|
+
website: "https://mytoken.io",
|
|
106
|
+
});
|
|
132
107
|
|
|
133
|
-
|
|
134
|
-
await rc.
|
|
135
|
-
await rc.unstake(wallet, { amount: 500 });
|
|
108
|
+
// Burn tokens
|
|
109
|
+
await rc.burn(wallet, 500);
|
|
136
110
|
```
|
|
137
111
|
|
|
138
|
-
|
|
112
|
+
## DEX (`rc.dex`)
|
|
139
113
|
|
|
140
114
|
```typescript
|
|
141
|
-
//
|
|
142
|
-
const pools = await rc.dex.getPools();
|
|
143
|
-
|
|
144
|
-
// Get pool details
|
|
145
|
-
const pool = await rc.dex.getPool('XRGE-MTK');
|
|
146
|
-
|
|
147
|
-
// Get swap quote
|
|
115
|
+
// Get a swap quote
|
|
148
116
|
const quote = await rc.dex.quote({
|
|
149
|
-
poolId:
|
|
150
|
-
tokenIn:
|
|
117
|
+
poolId: "XRGE-MTK",
|
|
118
|
+
tokenIn: "XRGE",
|
|
151
119
|
amountIn: 100,
|
|
152
120
|
});
|
|
121
|
+
console.log(`You'll receive ${quote.amount_out} MTK`);
|
|
153
122
|
|
|
154
|
-
// Execute swap
|
|
123
|
+
// Execute swap with slippage protection
|
|
155
124
|
await rc.dex.swap(wallet, {
|
|
156
|
-
tokenIn:
|
|
157
|
-
tokenOut:
|
|
125
|
+
tokenIn: "XRGE",
|
|
126
|
+
tokenOut: "MTK",
|
|
158
127
|
amountIn: 100,
|
|
159
|
-
minAmountOut:
|
|
128
|
+
minAmountOut: quote.amount_out * 0.98, // 2% slippage
|
|
160
129
|
});
|
|
161
130
|
|
|
162
|
-
// Create pool
|
|
131
|
+
// Create a new liquidity pool
|
|
163
132
|
await rc.dex.createPool(wallet, {
|
|
164
|
-
tokenA:
|
|
165
|
-
tokenB:
|
|
166
|
-
amountA:
|
|
167
|
-
amountB:
|
|
133
|
+
tokenA: "XRGE",
|
|
134
|
+
tokenB: "MTK",
|
|
135
|
+
amountA: 10_000,
|
|
136
|
+
amountB: 5_000,
|
|
168
137
|
});
|
|
169
138
|
|
|
170
139
|
// Add / remove liquidity
|
|
171
|
-
await rc.dex.addLiquidity(wallet, {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
140
|
+
await rc.dex.addLiquidity(wallet, {
|
|
141
|
+
poolId: "XRGE-MTK",
|
|
142
|
+
amountA: 1000,
|
|
143
|
+
amountB: 500,
|
|
144
|
+
});
|
|
145
|
+
await rc.dex.removeLiquidity(wallet, { poolId: "XRGE-MTK", lpAmount: 100 });
|
|
177
146
|
```
|
|
178
147
|
|
|
179
|
-
|
|
148
|
+
## NFTs (`rc.nft`)
|
|
180
149
|
|
|
181
|
-
|
|
150
|
+
RC-721 standard with collections, royalties, freezing, and batch minting.
|
|
182
151
|
|
|
183
152
|
```typescript
|
|
184
|
-
// Create a collection
|
|
153
|
+
// Create a collection (5% royalty, max 10k supply)
|
|
185
154
|
await rc.nft.createCollection(wallet, {
|
|
186
|
-
symbol:
|
|
187
|
-
name:
|
|
188
|
-
royaltyBps: 500,
|
|
189
|
-
maxSupply:
|
|
190
|
-
description: 'A post-quantum NFT collection',
|
|
155
|
+
symbol: "ART",
|
|
156
|
+
name: "My Art Collection",
|
|
157
|
+
royaltyBps: 500,
|
|
158
|
+
maxSupply: 10_000,
|
|
191
159
|
});
|
|
192
160
|
|
|
193
|
-
// Mint
|
|
161
|
+
// Mint
|
|
194
162
|
await rc.nft.mint(wallet, {
|
|
195
|
-
collectionId:
|
|
196
|
-
name:
|
|
197
|
-
metadataUri:
|
|
198
|
-
attributes: { rarity:
|
|
163
|
+
collectionId: "abc123",
|
|
164
|
+
name: "Piece #1",
|
|
165
|
+
metadataUri: "https://example.com/nft/1.json",
|
|
166
|
+
attributes: { rarity: "legendary" },
|
|
199
167
|
});
|
|
200
168
|
|
|
201
|
-
// Batch mint (up to 50)
|
|
169
|
+
// Batch mint (up to 50 at once)
|
|
202
170
|
await rc.nft.batchMint(wallet, {
|
|
203
|
-
collectionId:
|
|
204
|
-
names: [
|
|
205
|
-
uris: ['https://example.com/1.json', 'https://example.com/2.json', 'https://example.com/3.json'],
|
|
171
|
+
collectionId: "abc123",
|
|
172
|
+
names: ["#1", "#2", "#3"],
|
|
206
173
|
});
|
|
207
174
|
|
|
208
|
-
// Transfer with
|
|
175
|
+
// Transfer with sale price (triggers royalty)
|
|
209
176
|
await rc.nft.transfer(wallet, {
|
|
210
|
-
collectionId:
|
|
177
|
+
collectionId: "abc123",
|
|
211
178
|
tokenId: 1,
|
|
212
179
|
to: buyerPubKey,
|
|
213
|
-
salePrice: 100,
|
|
180
|
+
salePrice: 100,
|
|
214
181
|
});
|
|
215
182
|
|
|
216
|
-
//
|
|
217
|
-
await rc.nft.burn(wallet, { collectionId: 'abc123', tokenId: 1 });
|
|
218
|
-
await rc.nft.lock(wallet, { collectionId: 'abc123', tokenId: 2, locked: true });
|
|
219
|
-
await rc.nft.freezeCollection(wallet, { collectionId: 'abc123', frozen: true });
|
|
220
|
-
|
|
221
|
-
// Queries
|
|
222
|
-
const collections = await rc.nft.getCollections();
|
|
223
|
-
const collection = await rc.nft.getCollection('abc123');
|
|
224
|
-
const tokens = await rc.nft.getTokens('abc123', { limit: 20, offset: 0 });
|
|
225
|
-
const token = await rc.nft.getToken('abc123', 1);
|
|
183
|
+
// Query
|
|
226
184
|
const myNfts = await rc.nft.getByOwner(wallet.publicKey);
|
|
227
185
|
```
|
|
228
186
|
|
|
229
|
-
|
|
187
|
+
## Bridge (`rc.bridge`)
|
|
230
188
|
|
|
231
|
-
Bridge between Base Sepolia
|
|
189
|
+
Bridge assets between **Base Sepolia** and **RougeChain L1**. Supports ETH ↔ qETH, USDC ↔ qUSDC, and XRGE.
|
|
232
190
|
|
|
233
191
|
```typescript
|
|
234
|
-
// Check bridge status
|
|
192
|
+
// Check bridge status & supported tokens
|
|
235
193
|
const config = await rc.bridge.getConfig();
|
|
236
|
-
// { enabled: true,
|
|
194
|
+
// { enabled: true, supportedTokens: ["ETH", "USDC"], chainId: 84532 }
|
|
237
195
|
|
|
238
|
-
//
|
|
239
|
-
await rc.bridge.
|
|
240
|
-
|
|
241
|
-
evmAddress:
|
|
196
|
+
// Claim qETH after depositing ETH to custody address
|
|
197
|
+
await rc.bridge.claim({
|
|
198
|
+
evmTxHash: "0x...",
|
|
199
|
+
evmAddress: "0x...",
|
|
200
|
+
evmSignature: "0x...",
|
|
201
|
+
recipientPubkey: wallet.publicKey,
|
|
202
|
+
token: "ETH",
|
|
242
203
|
});
|
|
243
204
|
|
|
244
|
-
// Claim
|
|
205
|
+
// Claim qUSDC after depositing USDC
|
|
245
206
|
await rc.bridge.claim({
|
|
246
|
-
evmTxHash:
|
|
247
|
-
evmAddress:
|
|
248
|
-
evmSignature:
|
|
207
|
+
evmTxHash: "0x...",
|
|
208
|
+
evmAddress: "0x...",
|
|
209
|
+
evmSignature: "0x...",
|
|
249
210
|
recipientPubkey: wallet.publicKey,
|
|
211
|
+
token: "USDC",
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Withdraw qETH → receive ETH on Base Sepolia
|
|
215
|
+
await rc.bridge.withdraw(wallet, {
|
|
216
|
+
amount: 500_000,
|
|
217
|
+
evmAddress: "0xYourAddress",
|
|
218
|
+
tokenSymbol: "qETH",
|
|
250
219
|
});
|
|
251
220
|
|
|
252
|
-
//
|
|
253
|
-
const
|
|
221
|
+
// XRGE bridge
|
|
222
|
+
const xrgeConfig = await rc.bridge.getXrgeConfig();
|
|
223
|
+
await rc.bridge.withdrawXrge(wallet, {
|
|
224
|
+
amount: 1000,
|
|
225
|
+
evmAddress: "0xYourAddress",
|
|
226
|
+
});
|
|
254
227
|
```
|
|
255
228
|
|
|
256
|
-
|
|
229
|
+
## Mail (`rc.mail`)
|
|
257
230
|
|
|
258
|
-
|
|
231
|
+
On-chain encrypted email with `@rouge.quant` addresses.
|
|
259
232
|
|
|
260
233
|
```typescript
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const payload = {
|
|
264
|
-
type: 'transfer' as const,
|
|
234
|
+
// Send an encrypted email
|
|
235
|
+
await rc.mail.send({
|
|
265
236
|
from: wallet.publicKey,
|
|
266
|
-
to:
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
};
|
|
237
|
+
to: recipientPubKey,
|
|
238
|
+
subject: "Hello",
|
|
239
|
+
body: "This is a test",
|
|
240
|
+
encrypted_subject: encryptedSubject,
|
|
241
|
+
encrypted_body: encryptedBody,
|
|
242
|
+
});
|
|
273
243
|
|
|
274
|
-
|
|
275
|
-
const
|
|
244
|
+
// Read inbox
|
|
245
|
+
const inbox = await rc.mail.getInbox(wallet.publicKey);
|
|
246
|
+
|
|
247
|
+
// Move to trash
|
|
248
|
+
await rc.mail.move(messageId, "trash");
|
|
249
|
+
|
|
250
|
+
// Mark as read
|
|
251
|
+
await rc.mail.markRead(messageId);
|
|
276
252
|
```
|
|
277
253
|
|
|
278
|
-
##
|
|
254
|
+
## Messenger (`rc.messenger`)
|
|
279
255
|
|
|
280
|
-
|
|
256
|
+
End-to-end encrypted messaging with media and self-destruct support.
|
|
281
257
|
|
|
282
|
-
|
|
258
|
+
```typescript
|
|
259
|
+
// Register wallet for messaging
|
|
260
|
+
await rc.messenger.registerWallet({
|
|
261
|
+
id: wallet.publicKey,
|
|
262
|
+
displayName: "Alice",
|
|
263
|
+
signingPublicKey: wallet.publicKey,
|
|
264
|
+
encryptionPublicKey: encPubKey,
|
|
265
|
+
});
|
|
283
266
|
|
|
284
|
-
|
|
267
|
+
// Create a conversation
|
|
268
|
+
const result = await rc.messenger.createConversation([
|
|
269
|
+
wallet.publicKey,
|
|
270
|
+
recipientPubKey,
|
|
271
|
+
]);
|
|
285
272
|
|
|
286
|
-
|
|
273
|
+
// Fetch conversations (with extended key matching)
|
|
274
|
+
const convos = await rc.messenger.getConversations(wallet.publicKey, {
|
|
275
|
+
signingPublicKey: wallet.publicKey,
|
|
276
|
+
encryptionPublicKey: encPubKey,
|
|
277
|
+
});
|
|
287
278
|
|
|
288
|
-
|
|
279
|
+
// Send an encrypted message (with optional self-destruct)
|
|
280
|
+
await rc.messenger.sendMessage(conversationId, wallet.publicKey, encryptedContent, {
|
|
281
|
+
selfDestruct: true,
|
|
282
|
+
destructAfterSeconds: 30,
|
|
283
|
+
});
|
|
289
284
|
|
|
290
|
-
|
|
285
|
+
// Read messages
|
|
286
|
+
const messages = await rc.messenger.getMessages(conversationId);
|
|
291
287
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const rc = new RougeChain('https://testnet.rougechain.io/api', { fetch });
|
|
288
|
+
// Delete a message
|
|
289
|
+
await rc.messenger.deleteMessage(messageId);
|
|
295
290
|
```
|
|
296
291
|
|
|
297
|
-
|
|
292
|
+
## Low-Level Signing
|
|
298
293
|
|
|
299
|
-
|
|
294
|
+
For advanced use cases:
|
|
300
295
|
|
|
301
296
|
```typescript
|
|
302
|
-
import
|
|
303
|
-
|
|
297
|
+
import { signTransaction, verifyTransaction, generateNonce } from "@rougechain/sdk";
|
|
298
|
+
|
|
299
|
+
const payload = {
|
|
300
|
+
type: "transfer" as const,
|
|
301
|
+
from: wallet.publicKey,
|
|
302
|
+
to: recipient,
|
|
303
|
+
amount: 100,
|
|
304
|
+
fee: 1,
|
|
305
|
+
token: "XRGE",
|
|
306
|
+
timestamp: Date.now(),
|
|
307
|
+
nonce: generateNonce(),
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const signedTx = signTransaction(payload, wallet.privateKey, wallet.publicKey);
|
|
311
|
+
const valid = verifyTransaction(signedTx); // true
|
|
304
312
|
```
|
|
305
313
|
|
|
314
|
+
## Environment Support
|
|
315
|
+
|
|
316
|
+
| Environment | Notes |
|
|
317
|
+
|-------------|-------|
|
|
318
|
+
| **Browser** | Works with any bundler (Vite, webpack, etc.) |
|
|
319
|
+
| **Node.js 18+** | Works out of the box |
|
|
320
|
+
| **Node.js < 18** | Pass a fetch polyfill: `new RougeChain(url, { fetch })` |
|
|
321
|
+
| **React Native** | Install `react-native-get-random-values` before importing |
|
|
322
|
+
|
|
306
323
|
## TypeScript
|
|
307
324
|
|
|
308
|
-
|
|
325
|
+
Written in TypeScript with full type declarations shipped. All interfaces are exported:
|
|
309
326
|
|
|
310
327
|
```typescript
|
|
311
328
|
import type {
|
|
312
|
-
Block,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
NftToken,
|
|
317
|
-
LiquidityPool,
|
|
318
|
-
BalanceResponse,
|
|
319
|
-
Validator,
|
|
320
|
-
BridgeConfig,
|
|
321
|
-
WalletKeys,
|
|
322
|
-
ApiResponse,
|
|
323
|
-
} from '@rougechain/sdk';
|
|
329
|
+
Block, Transaction, TokenMetadata, NftCollection,
|
|
330
|
+
NftToken, LiquidityPool, BalanceResponse, Validator,
|
|
331
|
+
BridgeConfig, MailMessage, MessengerMessage, WalletKeys,
|
|
332
|
+
} from "@rougechain/sdk";
|
|
324
333
|
```
|
|
325
334
|
|
|
326
335
|
## Security
|
|
327
336
|
|
|
328
|
-
- **Post-quantum cryptography
|
|
329
|
-
- **Client-side signing
|
|
330
|
-
- **No key storage
|
|
337
|
+
- **Post-quantum cryptography** — All signatures use ML-DSA-65 (CRYSTALS-Dilithium), resistant to quantum computer attacks
|
|
338
|
+
- **Client-side signing** — Private keys never leave your application
|
|
339
|
+
- **No key storage** — The SDK does not store or transmit keys
|
|
340
|
+
|
|
341
|
+
## Links
|
|
342
|
+
|
|
343
|
+
- [Website](https://rougechain.io)
|
|
344
|
+
- [Documentation](https://docs.rougechain.io)
|
|
345
|
+
- [Chrome Extension](https://chromewebstore.google.com/detail/rougechain-wallet)
|
|
346
|
+
- [GitHub](https://github.com/cyberdreadx/quantum-vault)
|
|
331
347
|
|
|
332
348
|
## License
|
|
333
349
|
|
|
334
|
-
MIT
|
|
350
|
+
MIT © [RougeChain](https://rougechain.io)
|