Skip to content

Commit c644826

Browse files
committed
wallet docs
1 parent 778b22c commit c644826

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default withMermaid(defineConfig({
6060
items: [
6161
{ text: 'Introduction', link: '/mobile/index' },
6262
{ text: 'Session', link: '/mobile/session' },
63+
{ text: 'Wallet', link: '/mobile/wallet' },
6364
]
6465
},
6566
{

docs/mobile/wallet.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Wallet
2+
3+
ndk-mobile makes operating with nostr wallets as seamless as possible.
4+
5+
## Initialize
6+
7+
When setting up your NDKSession provider, make sure to activate the wallet prop, to indicate you want to enable this feature.
8+
9+
```ts
10+
<NDKSessionProvider wallet={true}>
11+
```
12+
13+
If your user has implicitly or explicitly enabled a wallet in your app you can also pass the configuration into the provider to immediately make the wallet available throughout your app.
14+
15+
```ts
16+
const walletConfig = {
17+
// type of wallet to enable
18+
type: 'nip-60',
19+
20+
// some wallet Id this user can use
21+
walletId: 'naddr1qvzqqqy3lupzq8mxja28nlfd6269zzzsm8feqxrl5eapf7g5fretnpucjh0xlannqythwumn8ghj7un9d3shjtnswf5k6ctv9ehx2ap0qqgx5un0weuxsmp5w4ax2e3cwe382kngsvc'
22+
23+
<NDKSessionProvider wallet={true} walletConfig={walletConfig}>
24+
```
25+
26+
## Using the wallet
27+
28+
Now from within your app you can easily zap via the `NDKZapper`, check balance, receive payments, and any other interaction you can use `ndk-wallet`.
29+
30+
```ts
31+
const { activeWallet, balances } = useNDKSession();
32+
33+
async function generateDeposit() {
34+
const deposit = activeWallet.deposit(10, activeWallet.mints[0], 'sat');
35+
deposit.on('success', () => console.log('✅ deposit'))
36+
const bolt11 = await deposit.start();
37+
console.log('pay this LN invoice', bolt11);
38+
}
39+
40+
return (
41+
<View>
42+
<Text>Wallet balances = {JSON.stringify(balances)}</Text>
43+
44+
<Button title="Add 10 sats" onPress={generateDeposit}>
45+
</View>
46+
)
47+
```

0 commit comments

Comments
 (0)