You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/network/8-flare-tx-sdk.mdx
+34-24Lines changed: 34 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,9 @@ description: Software Development Kit for performing common operations on Flare.
5
5
keywords: [sdk, flare-network, developer tools]
6
6
---
7
7
8
+
importTabsfrom"@theme/Tabs";
9
+
importTabItemfrom"@theme/TabItem";
10
+
8
11
Flare Transaction SDK ([`@flarenetwork/flare-tx-sdk`](https://www.npmjs.com/package/@flarenetwork/flare-tx-sdk/)) is the official Node.js Software Development Kit for performing common actions on Flare's networks:
9
12
10
13
- Retrieving account and balance information
@@ -33,9 +36,23 @@ Before you start, ensure you have the following:
33
36
34
37
To get started, install the SDK into your Node.js project:
35
38
36
-
```bash
37
-
npm install @flarenetwork/flare-tx-sdk
38
-
```
39
+
<Tabs>
40
+
<TabItemvalue="npm"label="npm"default>
41
+
42
+
```bash
43
+
npm install @flarenetwork/flare-tx-sdk
44
+
```
45
+
46
+
</TabItem>
47
+
<TabItemvalue="yarn"label="yarn">
48
+
49
+
```bash
50
+
yarn add @flarenetwork/flare-tx-sdk
51
+
```
52
+
53
+
</TabItem>
54
+
55
+
</Tabs>
39
56
40
57
## Core concepts
41
58
@@ -77,18 +94,11 @@ async function main() {
77
94
console.log("Fetching balance...");
78
95
constbalance=awaitnetwork.getBalance(publicKey);
79
96
console.log("✅ Balance retrieved successfully!");
80
-
81
97
// All amounts are returned as wei
82
98
console.log(` - Available on C-Chain: ${balance.availableOnC} wei`);
83
99
console.log(` - Wrapped on C-Chain: ${balance.wrappedOnC} wei`);
84
100
console.log(` - Available on P-Chain: ${balance.availableOnP} wei`);
85
101
console.log(` - Staked on P-Chain: ${balance.stakedOnP} wei`);
86
-
console.log(
87
-
` - Not yet imported to C-Chain: ${balance.notImportedToC} wei`,
88
-
);
89
-
console.log(
90
-
` - Not yet imported to P-Chain: ${balance.notImportedToP} wei`,
91
-
);
92
102
}
93
103
94
104
main().catch(console.error);
@@ -202,7 +212,7 @@ You can also pass additional parameters to modify:
let states =awaitnetwork.getStateOfFtsoRewards(cAddress);
@@ -217,6 +227,8 @@ It can be empty or it consists of objects of type [`FtsoRewardState`](https://gi
217
227
-`claimType` (string) - The type of claim (`DIRECT`, `FEE`, `WNAT`, `MIRROR`, or `CCHAIN`).
218
228
-`initialised` (boolean) - flag indicating if the reward can be claimed without providing proofs.
219
229
230
+
#### Claim with proofs
231
+
220
232
Rewards that are not initialized can be claimed using Merkle proofs available in the [flare-foundation/fsp-rewards](https://github.com/flare-foundation/fsp-rewards/) repository.
221
233
222
234
```javascript
@@ -329,15 +341,9 @@ The SDK streamlines this cross-chain process.
329
341
330
342
## Wallet controllers
331
343
332
-
To sign transactions, you must provide an object that implements the [`Wallet`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/index.ts)interface.
344
+
A controller is a helper class that wraps a standard wallet library (like EIP-1193 for MetaMask or Zondax for Ledger) and produces SDK-compatible [`Wallet`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/index.ts)objects.
333
345
The SDK includes controllers for popular wallet standards to make this easy.
334
346
335
-
:::tip[What is a Wallet Controller?]
336
-
337
-
A controller is a helper class that wraps a standard wallet library (like EIP-1193 for MetaMask or Zondax for Ledger) and produces SDK-compatible `Wallet` objects.
338
-
339
-
:::
340
-
341
347
### EIP-1193 Wallets
342
348
343
349
Use the [`EIP1193WalletController`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/eip1193/controller.ts) for any browser-based wallet that exposes an EIP-1193 provider (`window.ethereum`) such as MetaMask or WalletConnect.
Use the [`LedgerWalletController`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/ledger/controller.ts) with the [@zondax/ledger-flare](https://www.npmjs.com/package/@zondax/ledger-flare) or [@ledgerHQ/hw-app-eth](https://www.npmjs.com/package/@ledgerhq/hw-app-eth) libraries to sign with a Ledger device.
369
+
Use the [`LedgerWalletController`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/ledger/controller.ts) with either [`@zondax/ledger-flare`](https://www.npmjs.com/package/@zondax/ledger-flare) or [`@ledgerHQ/hw-app-eth`](https://www.npmjs.com/package/@ledgerhq/hw-app-eth) libraries to sign with a Ledger device.
For fine-grained control and monitoring, you can register callbacks that fire at different stages of a transaction's lifecycle.
407
+
For fine-grained control and monitoring, you can register [callbacks](https://github.com/flare-foundation/flare-tx-sdk/blob/main/src/network/callback.ts) that fire at different stages of a transaction's lifecycle.
408
+
All
402
409
This is useful for UI updates, logging, or offline signing workflows.
403
410
404
411
```javascript
@@ -409,6 +416,7 @@ This is useful for UI updates, logging, or offline signing workflows.
409
416
// Returning `false` will cancel the signing request.
0 commit comments