|
1 | 1 | --- |
2 | 2 | title: Dusk Connect |
3 | | -description: Integrate Dusk wallet discovery and account connection into applications. |
| 3 | +description: Connect Dusk applications to compatible wallet extensions with @dusk/connect. |
4 | 4 | --- |
5 | 5 |
|
6 | | -Dusk Connect is the wallet integration layer for Dusk applications. It gives dApps a consistent way to discover compatible wallets, request accounts, and build connection flows around Dusk accounts. |
| 6 | +Dusk Connect (`@dusk/connect`) is the wallet integration layer for browser dApps on Dusk. It discovers compatible wallet extensions, requests profile access, tracks the active wallet and network, and sends user-approved transactions through the selected wallet. |
7 | 7 |
|
8 | | -Use Dusk Connect when your application needs to: |
| 8 | +The SDK is framework-agnostic, typed, and has no runtime dependencies. An optional modal and `<dusk-connect-button>` are available from `@dusk/connect/ui`. |
9 | 9 |
|
10 | | -- detect compatible Dusk wallet providers |
11 | | -- let users select a wallet |
12 | | -- request account access |
13 | | -- handle public and shielded account flows in a consistent UI |
14 | | -- integrate with Dusk wallet software without hardcoding one provider |
| 10 | +## Install |
15 | 11 |
|
16 | | -## Where it fits |
| 12 | +Dusk Connect is published on JSR: |
| 13 | + |
| 14 | +```bash |
| 15 | +npx jsr add @dusk/connect |
| 16 | +``` |
| 17 | + |
| 18 | +For Deno: |
17 | 19 |
|
18 | | -Dusk applications often need two kinds of integration: |
| 20 | +```bash |
| 21 | +deno add jsr:@dusk/connect |
| 22 | +``` |
19 | 23 |
|
20 | | -- **Network integration**: read chain data, submit transactions, and observe events. |
21 | | -- **Wallet integration**: ask a user to connect an account and approve actions. |
| 24 | +## Connect a wallet |
22 | 25 |
|
23 | | -Dusk Connect is for the wallet side. For network APIs and transaction flow, see [Transaction Lifecycle](/developer/integrations/tx-lifecycle), [HTTP API](/developer/integrations/http-api), and [W3sper SDK](/developer/integrations/w3sper). |
| 26 | +`createDuskWallet()` starts wallet discovery and exposes a reactive view of the connection: |
24 | 27 |
|
25 | | -If you are testing against the first-party browser wallet, use the [Dusk Wallet Extension](/developer/integrations/wallet-extension) as one compatible provider. |
| 28 | +```js |
| 29 | +import { createDuskWallet } from "@dusk/connect"; |
26 | 30 |
|
27 | | -## Typical flow |
| 31 | +const wallet = createDuskWallet(); |
| 32 | +await wallet.ready(); |
28 | 33 |
|
29 | | -A dApp integration usually follows this shape: |
| 34 | +if (wallet.state.availableProviders.length > 1 && !wallet.state.providerId) { |
| 35 | + await wallet.selectProvider(wallet.state.availableProviders[0].uuid); |
| 36 | +} |
30 | 37 |
|
31 | | -1. Discover available Dusk wallet providers. |
32 | | -2. Show the user the compatible wallets. |
33 | | -3. Request account access from the selected wallet. |
34 | | -4. Store the active account and provider for the session. |
35 | | -5. Ask the wallet to approve transactions or account actions when needed. |
| 38 | +const profiles = await wallet.connect(); |
| 39 | +console.log(profiles[0]); |
| 40 | +``` |
| 41 | + |
| 42 | +`wallet.connect()` opens the selected wallet's approval flow. The wallet state updates when the user changes profile, account access, or network. Use `wallet.subscribe()` to update application state reactively. |
| 43 | + |
| 44 | +## Where it fits |
36 | 45 |
|
37 | | -The exact API depends on the version of Dusk Connect you integrate. |
| 46 | +Use Dusk Connect for user-facing wallet flows: |
38 | 47 |
|
39 | | -## Repository |
| 48 | +- discover one or more compatible wallet extensions |
| 49 | +- let the user select a wallet and grant profile access |
| 50 | +- access public accounts and request shielded receive addresses |
| 51 | +- request message signatures and user-approved transactions |
| 52 | +- react to profile, authorization, and network changes |
40 | 53 |
|
41 | | -The Dusk Connect SDK is developed in the Dusk Network GitHub organization: |
| 54 | +For a native smart-contract dApp, `createDuskApp()` adds read-only contract calls, data-driver loading, and prepared contract writes to the same wallet connection. Use [W3sper](/developer/integrations/w3sper/) or the [HTTP API](/developer/integrations/http-api/) when an application or backend needs direct node access without an injected wallet. |
42 | 55 |
|
43 | | -- <a href="https://github.com/dusk-network/connect" target="_blank" rel="noreferrer">dusk-network/connect</a> |
| 56 | +The [Dusk Wallet Extension](/developer/integrations/wallet-extension/) is the first-party wallet provider for testing this flow. Dusk Connect uses the Dusk discovery protocol instead of hardcoding a particular extension. |
44 | 57 |
|
45 | | -## Read next |
| 58 | +## Next steps |
46 | 59 |
|
47 | | -- [Dusk Wallet Extension](/developer/integrations/wallet-extension) |
48 | | -- [Web Wallet](/learn/web-wallet) |
49 | | -- [Transaction Lifecycle](/developer/integrations/tx-lifecycle) |
50 | | -- [W3sper SDK](/developer/integrations/w3sper) |
| 60 | +- [Dusk Connect repository and API reference](https://github.com/dusk-network/connect) |
| 61 | +- [Dusk Wallet Extension](/developer/integrations/wallet-extension/) |
| 62 | +- [Transaction Lifecycle](/developer/integrations/tx-lifecycle/) |
| 63 | +- [W3sper SDK](/developer/integrations/w3sper/) |
0 commit comments