|
| 1 | +--- |
| 2 | +title: Bloom |
| 3 | +--- |
| 4 | + |
| 5 | +# {$frontmatter.title} |
| 6 | + |
| 7 | +Wallet module for connecting Bloom to web3-onboard. |
| 8 | + |
| 9 | +## Install |
| 10 | + |
| 11 | +<Tabs values={['yarn', 'npm']}> |
| 12 | +<TabPanel value="yarn"> |
| 13 | + |
| 14 | +```sh copy |
| 15 | +yarn add @web3-onboard/bloom |
| 16 | +``` |
| 17 | + |
| 18 | + </TabPanel> |
| 19 | + <TabPanel value="npm"> |
| 20 | + |
| 21 | +```sh copy |
| 22 | +npm install @web3-onboard/bloom |
| 23 | +``` |
| 24 | + |
| 25 | + </TabPanel> |
| 26 | +</Tabs> |
| 27 | + |
| 28 | + |
| 29 | +```typescript |
| 30 | +type WalletConnectOptions = { |
| 31 | + /** |
| 32 | + * Project ID associated with [WalletConnect account](https://cloud.walletconnect.com) |
| 33 | + */ |
| 34 | + projectId: string |
| 35 | + /** |
| 36 | + * Defaults to `appMetadata.explore` that is supplied to the web3-onboard init |
| 37 | + * Strongly recommended to provide atleast one URL as it is required by some wallets (i.e. MetaMask) |
| 38 | + * To connect with walletconnect |
| 39 | + */ |
| 40 | + dappUrl?: string |
| 41 | + /** |
| 42 | + * List of Required Chain(s) ID for wallets to support in number format (integer or hex) |
| 43 | + * Defaults to [1] - Ethereum |
| 44 | + */ |
| 45 | + requiredChains?: number[] | undefined |
| 46 | + /** |
| 47 | + * List of Optional Chain(s) ID for wallets to support in number format (integer or hex) |
| 48 | + * Defaults to the chains provided within the web3-onboard init chain property |
| 49 | + */ |
| 50 | + optionalChains?: number[] | undefined |
| 51 | + /** |
| 52 | + * Additional required methods to be added to the default list of ['eth_sendTransaction', 'personal_sign'] |
| 53 | + * Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/advanced/providers/ethereum#required-and-optional-methods |
| 54 | + */ |
| 55 | + additionalRequiredMethods?: string[] | undefined |
| 56 | + /** |
| 57 | + * Additional methods to be added to the default list of ['eth_sendTransaction', 'eth_signTransaction', 'personal_sign', 'eth_sign', 'eth_signTypedData', 'eth_signTypedData_v4'] |
| 58 | + * Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/web/walletConnectModal/options |
| 59 | + */ |
| 60 | + additionalOptionalMethods?: string[] | undefined |
| 61 | +) |
| 62 | +``` |
| 63 | +
|
| 64 | +## Usage |
| 65 | +
|
| 66 | +```typescript |
| 67 | +import Onboard from '@web3-onboard/core' |
| 68 | +import bloomModule from '@web3-onboard/bloom' |
| 69 | + |
| 70 | +const wcInitOptions = { |
| 71 | + /** |
| 72 | + * Project ID associated with [WalletConnect account](https://cloud.walletconnect.com) |
| 73 | + */ |
| 74 | + projectId: 'abc123...', |
| 75 | + /** |
| 76 | + * Chains required to be supported by all wallets connecting to your DApp |
| 77 | + */ |
| 78 | + requiredChains: [1], |
| 79 | + /** |
| 80 | + * Chains required to be supported by all wallets connecting to your DApp |
| 81 | + */ |
| 82 | + optionalChains: [42161, 8453, 10, 137, 56], |
| 83 | + /** |
| 84 | + * Defaults to `appMetadata.explore` that is supplied to the web3-onboard init |
| 85 | + * Strongly recommended to provide atleast one URL as it is required by some wallets (i.e. MetaMask) |
| 86 | + * To connect with WalletConnect |
| 87 | + */ |
| 88 | + dappUrl: 'http://YourAwesomeDapp.com' |
| 89 | +} |
| 90 | + |
| 91 | +// initialize the module with options |
| 92 | +const bloom = bloomModule(wcInitOptions) |
| 93 | + |
| 94 | +// can also initialize with no options... |
| 95 | + |
| 96 | +const onboard = Onboard({ |
| 97 | + // ... other Onboard options |
| 98 | + wallets: [ |
| 99 | + bloom |
| 100 | + //... other wallets |
| 101 | + ] |
| 102 | +}) |
| 103 | + |
| 104 | +const connectedWallets = await onboard.connectWallet() |
| 105 | + |
| 106 | +// Assuming only wallet connect is connected, index 0 |
| 107 | +// `instance` will give insight into the WalletConnect info |
| 108 | +// such as namespaces, methods, chains, etc per wallet connected |
| 109 | +const { instance } = connectedWallets[0] |
| 110 | + |
| 111 | +console.log(connectedWallets) |
| 112 | +``` |
| 113 | +
|
| 114 | +## Build Environments |
| 115 | +
|
| 116 | +For build env configurations and setups please see the Build Env section [here](/docs/modules/core#build-environments) |
0 commit comments