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
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,22 +9,22 @@ import Tabs from "@theme/Tabs";
9
9
importTabItemfrom"@theme/TabItem";
10
10
importDocCardListfrom"@theme/DocCardList";
11
11
12
-
The Flare Transaction SDK ([`@flarenetwork/flare-tx-sdk`](https://www.npmjs.com/package/@flarenetwork/flare-tx-sdk/)) is the official Node.js toolkit for performing common actions on all Flare networks:
12
+
The Flare Transaction SDK ([`@flarenetwork/flare-tx-sdk`](https://www.npmjs.com/package/@flarenetwork/flare-tx-sdk/)) is the official Node.js toolkit for performing common actions on all Flare networks - Flare, Coston2, Songbird, and Coston.
The SDK separates network logic from account management.
58
+
This ensures the same wallet can be used across multiple networks without code changes.
58
59
59
60
-**`Network`**: Represents the blockchain network you want to connect to. Available networks include:
60
61
-`Network.FLARE`
62
+
-`Network.COSTON2`
61
63
-`Network.SONGBIRD`
62
64
-`Network.COSTON`
63
-
-`Network.COSTON2`
64
65
65
66
The `Network` object provides methods to query balances, transfer tokens, claim rewards, and interact with contracts.
67
+
It uses Flare's [public RPCs](/network/overview#configuration) by default.
66
68
67
69
-**`Wallet`**: Represents a user account. The SDK does not store private keys. Instead, it defines a `Wallet` interface which can be implemented by:
68
70
- MetaMask and other browser wallets (`EIP1193WalletController`)
@@ -116,30 +118,30 @@ Example output:
116
118
}
117
119
```
118
120
119
-
:::note[Units]
121
+
:::info[Units]
120
122
121
123
The SDK uses nats (smallest unit of FLR, equivalent to wei).
122
-
Use helpers such as`Amount.nats(x)` for FLR and `Amount.wnats(x)` for WFLR.
124
+
Use helpers methods`Amount.nats(x)` for FLR and `Amount.wnats(x)` for WFLR.
123
125
124
126
:::
125
127
126
128
## Wallet controllers
127
129
128
-
The SDK doesn't store keys. Instead, it adapts external signers into a common[`Wallet`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/index.ts) interface via controllers.
129
-
This guide shows how to connect EIP-1193 wallets (e.g., MetaMask/WalletConnect), Ledger, Trezor, and how to author a custom wallet.
130
+
Wallet controllers adapt third-party wallets into the SDK's[`Wallet`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/index.ts) interface.
131
+
They handle signing and address derivation, while your keys remain securely stored in the original wallet.
130
132
131
-
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 objects.
132
-
The SDK includes controllers for popular wallet standards to make this easy.
133
+
This guide shows how to connect EIP-1193 wallets (e.g., MetaMask/WalletConnect) and hardware wallets (Ledger and Trezor).
133
134
134
-
:::tip
135
+
### EIP-1193 (MetaMask, WalletConnect)
135
136
136
-
If none of the Wallet controllers here meet your needs, you can implement a [custom wallet controller](/network/flare-tx-sdk/advanced-usage#custom-wallets).
137
+
Use the [`EIP1193WalletController`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/eip1193/controller.ts) with any browser wallet that exposes an EIP-1193 provider (e.g., `window.ethereum`).
137
138
138
-
:::
139
+
:::tip[Security]
139
140
140
-
### EIP-1193 (MetaMask, WalletConnect)
141
+
Your private keys **never** leave your wallet.
142
+
The SDK only communicates with the wallet for signing.
141
143
142
-
Use the [`EIP1193WalletController`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/eip1193/controller.ts) with any browser wallet that exposes an EIP-1193 provider (e.g., `window.ethereum`).
@@ -177,6 +179,13 @@ async function connectEip1193() {
177
179
Use the [`LedgerWalletController`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/ledger/controller.ts).
178
180
It supports either Zondax Flare App ([`@zondax/ledger-flare`](https://www.npmjs.com/package/@zondax/ledger-flare)) or Ledger ETH App ([`@ledgerHQ/hw-app-eth`](https://www.npmjs.com/package/@ledgerhq/hw-app-eth)).
179
181
182
+
:::tip[Security]
183
+
184
+
Your private keys **never** leave your Ledger device.
185
+
The SDK only communicates with the device for signing.
186
+
187
+
:::
188
+
180
189
1. **Installation:**
181
190
182
191
<Tabs groupId="ledger-connector">
@@ -233,7 +242,9 @@ It supports either Zondax Flare App ([`@zondax/ledger-flare`](https://www.npmjs.
233
242
import { Eth } from"@ledgerHQ/hw-app-eth"
234
243
235
244
asyncfunctionconnectLedgerViaEthApp() {
236
-
ethApp =Eth(...) // add transport here
245
+
// add Ledger transports here
246
+
// see https://developers.ledger.com/docs/device-interaction/integration/how_to/transports
@@ -255,6 +266,13 @@ It supports either Zondax Flare App ([`@zondax/ledger-flare`](https://www.npmjs.
255
266
256
267
Use the [`TrezorWalletController`](https://github.com/flare-foundation/flare-tx-sdk/blob/HEAD/src/wallet/trezor/controller.ts) with [Trezor Connect](https://connect.trezor.io/9/readme/connect/).
257
268
269
+
:::tip[Security]
270
+
271
+
Your private keys **never** leave your Trezor device.
272
+
The SDK only communicates with the device for signing.
273
+
274
+
:::
275
+
258
276
1. **Installation:**
259
277
260
278
```bash
@@ -268,7 +286,9 @@ Use the [`TrezorWalletController`](https://github.com/flare-foundation/flare-tx-
@@ -282,7 +302,14 @@ Use the [`TrezorWalletController`](https://github.com/flare-foundation/flare-tx-
282
302
}
283
303
```
284
304
305
+
:::info[Advanced]
306
+
307
+
If none of the Wallet controllers listed here meet your needs, you can implement a [custom wallet controller](/network/flare-tx-sdk/advanced-usage#custom-wallets).
308
+
309
+
:::
310
+
285
311
## Next steps
286
312
287
313
- Explore the [Cookbook](/network/flare-tx-sdk/cookbook) for task-oriented guides (balances, transfers, rewards, staking).
288
314
- Check the [Advanced Features](/network/flare-tx-sdk/advanced-usage) for transaction callbacks and custom wallets.
315
+
- Read the SDK source code on [GitHub](https://github.com/flare-foundation/flare-tx-sdk).
Withdrawing locked balance incurs a **penalty**, so the withdrawn amount will be reduced.
@@ -220,13 +226,14 @@ if (ftsoRewardAmount > 0) {
220
226
221
227
Optional parameters:
222
228
223
-
-`rewardOwner` (address) - C-chain address of the reward owner
224
-
-`recipient` (address) - C-chain address of where the reward should be transferred
229
+
-`rewardOwner` (address) - C-Chain address of the reward owner
230
+
-`recipient` (address) - C-Chain address of where the reward should be transferred
225
231
-`wrap` (bool) - transfer reward as native (default) or wrapped.
226
232
227
233
#### Claim with proofs
228
234
229
235
If a reward isn't initialized, you must provide a Merkle proof available in the [flare-foundation/fsp-rewards](https://github.com/flare-foundation/fsp-rewards/) repository.
236
+
As an example for reward epoch 320, see the proofs in [`reward-distribution-data.json`](https://github.com/flare-foundation/fsp-rewards/blob/main/flare/320/reward-distribution-data.json).
0 commit comments