Skip to content

Commit b9ae897

Browse files
Merge pull request #1033 from Web3Auth/coinbase-adapter
Improve Coinbase Adapter documentation
2 parents ca95444 + fa6ecd9 commit b9ae897

File tree

3 files changed

+87
-140
lines changed

3 files changed

+87
-140
lines changed

docs/sdk/pnp/web/adapters/coinbase.mdx

Lines changed: 81 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,17 @@ description: "Web3Auth PnP Web Adapter SDKs - Coinbase | Documentation - Web3Aut
99
import TabItem from "@theme/TabItem";
1010
import Tabs from "@theme/Tabs";
1111

12-
## [`@web3auth/coinbase-adapter`](https://npmjs.com/package/@web3auth/coinbase-adapter)
13-
14-
Coinbase adapter allows you to connect with coinbase wallet. You can read more about coinbase wallet
15-
here.(https://docs.cloud.coinbase.com/wallet-sdk/docs).
16-
17-
## Basic Details
18-
19-
#### Adapter Name: `coinbase`
20-
21-
#### Package Name: [`@web3auth/coinbase-adapter`](https://npmjs.com/package/@web3auth/coinbase-adapter)
22-
23-
#### authMode: `DAPP`
24-
25-
#### chainNamespace: `EIP155`
26-
27-
#### Default: `YES`
12+
The [`@web3auth/coinbase-adapter`](https://npmjs.com/package/@web3auth/coinbase-adapter) package
13+
enables you to connect with injected Coinbase wallet(Extension Wallet) and
14+
[Smart Wallet](https://www.smartwallet.dev/quick-start).
2815

2916
## Installation
3017

3118
```bash npm2yarn
3219
npm install --save @web3auth/coinbase-adapter
3320
```
3421

35-
## Arguments
22+
## Parameters
3623

3724
<Tabs
3825
defaultValue="table"
@@ -44,13 +31,13 @@ npm install --save @web3auth/coinbase-adapter
4431

4532
<TabItem value="table">
4633

47-
| Parameter | type |
48-
| ------------------ | -------------------------- |
49-
| `chainConfig?` | `CustomChainConfig` |
50-
| `adapterSettings?` | `CoinbaseWalletSDKOptions` |
51-
| `clientId?` | `string` |
52-
| `sessionTime?` | `number` |
53-
| `web3AuthNetwork?` | `WEB3AUTH_NETWORK_TYPE` |
34+
| Parameter | Description |
35+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36+
| `chainConfig?` | Custom Chain Configuration you want to connect with. Defaults to `chainConfig` passed to `EthereumPrivateKeyProvider`. |
37+
| `adapterSettings?` | Adapter settings to fine-tune the connection preferences, you can refer to [CoinbaseWalletSDKOptions](<[https://www.smartwallet.dev/sdk/create-coinbase-wallet-sdk#parameters](https://www.smartwallet.dev/sdk/create-coinbase-wallet-sdk#parameters)>) documentation. The default connection mode is set to "all," which means that users can connect either their Coinbase Injected Wallet or the Smart Wallet. |
38+
| `clientId?` | Client Id for Web3Auth. You can get the client id from Web3Auth Dashboard. |
39+
| `sessionTime?` | Allows you to configure the connection validity. Defaults to `sessionTime` passed to `Web3AuthOptions`. |
40+
| `web3AuthNetwork?` | Allows you to configure the `Web3AuthNetwork`. Defaults to `web3AuthNetwork` passed to `Web3AuthOptions.` |
5441

5542
</TabItem>
5643

@@ -67,104 +54,90 @@ interface CoinbaseAdapterOptions {
6754
```
6855

6956
</TabItem>
70-
7157
</Tabs>
7258

73-
### Custom Chain Config
74-
75-
#### `chainConfig`
76-
77-
:::warning
78-
79-
While you can pass your `chainConfig`, it is not required since you can directly pass it over to the
80-
`Web3Auth`/ `Web3AuthNoModal` configuration while instantiating it.
81-
82-
Read more about it in their respective sections:
83-
84-
- [`web3auth/modal`](/sdk/pnp/web/modal/initialize#adding-a-custom-chain-configuration)
85-
- [`web3auth/no-modal`](/sdk/pnp/web/no-modal/initialize#adding-a-custom-chain-configuration)
59+
## Usage
8660

87-
:::
88-
89-
:::warning
90-
91-
If you do pass `chainConfig` in an Adapter, it overwrites the `chainConfig` passed over to the
92-
`Web3Auth`/ `Web3AuthNoModal` constructor.
93-
94-
:::
95-
96-
#### `CoinbaseWalletSDKOptions`
97-
98-
Checkout the
99-
[Coinbase Wallet SDK Documentation](https://docs.cloud.coinbase.com/wallet-sdk/docs/initializing#initializing)
100-
for these options.
101-
102-
## Change Adapter Settings
103-
104-
You can change the adapter settings by calling the `setAdapterSettings()` function on the adapter
105-
instance.
61+
```tsx
62+
import { CoinbaseAdapter } from "@web3auth/coinbase-adapter";
10663

107-
### Arguments
64+
// focus-start
65+
const coinbaseAdapter = new CoinbaseAdapter({
66+
// This will only allow users to connect with Smart Wallet
67+
// By default, it's set to "all"
68+
adapterSettings: { options: "smartWalletOnly" },
69+
});
70+
// focus-end
10871

109-
<Tabs
110-
defaultValue="table"
111-
values={[
112-
{ label: "Table", value: "table" },
113-
{ label: "Interface", value: "interface" },
114-
]}
115-
>
72+
// Use your existing Web3Auth instance
73+
web3auth.configureAdapter(coinbaseAdapter);
74+
```
11675

117-
<TabItem value="table">
76+
## Use Smart Wallet Features
11877

119-
| Parameter | type |
120-
| ------------------ | ----------------------- |
121-
| `clientId?` | `string` |
122-
| `sessionTime?` | `number` |
123-
| `chainConfig?` | `CustomChainConfig` |
124-
| `web3AuthNetwork?` | `WEB3AUTH_NETWORK_TYPE` |
78+
The Web3Auth provider which is created using the Coinbase Wallet Adapter will be EIP 1193 compatible
79+
which means, you won't be able to use the Smart Wallet(ERC 4337) features directly
12580

126-
</TabItem>
81+
To use the Smart Wallet ERC 4337 features, you can use the Web3Auth provider to send JSON-RPC
82+
requests to the Smart Wallet. For batching and paymaster feature, it uses EIP 5792
83+
`wallet_sendCalls` method. [Learn more about EIP 5792](https://eips.ethereum.org/EIPS/eip-5792).
12784

128-
<TabItem value="interface">
85+
### Send Batch Requests
12986

13087
```tsx
131-
interface BaseAdapterSettings {
132-
clientId?: string;
133-
sessionTime?: number;
134-
chainConfig?: CustomChainConfig;
135-
web3AuthNetwork?: WEB3AUTH_NETWORK_TYPE;
136-
}
88+
// Retrive the Web3Auth provider once the connection is established
89+
const provider = web3auth.provider;
90+
91+
const response = await provider.request({
92+
method: "wallet_sendCalls",
93+
params: [
94+
{
95+
version: "1.0",
96+
chainId: "0x01",
97+
from: address[0],
98+
calls: [
99+
{
100+
to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
101+
value: "0x9184e72a",
102+
data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
103+
},
104+
{
105+
to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
106+
value: "0x182183",
107+
data: "0xfbadbaf01",
108+
},
109+
],
110+
},
111+
],
112+
});
137113
```
138114

139-
</TabItem>
140-
141-
</Tabs>
142-
143-
## Example
115+
### Use Paymaster
144116

145117
```tsx
146-
import { CoinbaseAdapter } from "@web3auth/coinbase-adapter";
147-
const coinbaseAdapter = new CoinbaseAdapter({
148-
clientId:
149-
"BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
150-
sessionTime: 3600, // 1 hour in seconds
151-
chainConfig: {
152-
chainNamespace: CHAIN_NAMESPACES.EIP155,
153-
chainId: "0x1",
154-
rpcTarget: "https://rpc.ankr.com/eth", // This is the public RPC we have added, please pass on your own endpoint while creating an app
155-
},
156-
web3AuthNetwork: "sapphire_mainnet",
157-
});
158-
web3auth.configureAdapter(coinbaseAdapter);
159-
160-
// You can also change the adapter settings later on
161-
coinbaseAdapter.setAdapterSettings({
162-
sessionTime: 86400, // 1 day in seconds
163-
chainConfig: {
164-
chainNamespace: CHAIN_NAMESPACES.EIP155,
165-
chainId: "0x1",
166-
rpcTarget: "https://rpc.ankr.com/eth", // This is the public RPC we have added, please pass on your own endpoint while creating an app
167-
},
168-
web3AuthNetwork: "sapphire_mainnet",
118+
// Retrive the Web3Auth provider once the connection is established
119+
const provider = web3auth.provider;
120+
121+
const response = await provider.request({
122+
method: "wallet_sendCalls",
123+
params: [
124+
{
125+
version: "1.0",
126+
chainId: "0x01",
127+
from: address[0],
128+
calls: [
129+
{
130+
to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
131+
value: "0x9184e72a",
132+
data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
133+
},
134+
],
135+
capabilities: {
136+
paymasterService: {
137+
url: "YOUR_PAYMASTER_URL",
138+
},
139+
},
140+
},
141+
],
169142
});
170143
```

docs/sdk/pnp/web/adapters/default-evm-adapter.mdx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,9 @@ description: "Web3Auth PnP Web Adapter SDKs - Default EVM Adapter | Documentatio
99
import TabItem from "@theme/TabItem";
1010
import Tabs from "@theme/Tabs";
1111

12-
## [`@web3auth/default-evm-adapter`](https://npmjs.com/package/@web3auth/default-evm-adapter)
13-
14-
The default EVM adapter enables seamless detection of injected EVM wallets and
15-
WalletConnect-supported wallets, allowing interaction with just a single line of code.
16-
17-
## Basic Details
18-
19-
#### Adapter Name: `default-evm-adapter`
20-
21-
#### Package Name: [`@web3auth/default-evm-adapter`](https://npmjs.com/package/@web3auth/default-evm-adapter)
22-
23-
#### authMode: `DAPP`
24-
25-
#### chainNamespace: `EIP155`
26-
27-
#### Default: `NO`
12+
The [`@web3auth/default-evm-adapter`](https://npmjs.com/package/@web3auth/default-evm-adapter)
13+
package enables seamless detection of injected EVM wallets and WalletConnect-supported wallets,
14+
allowing interaction with just a single line of code.
2815

2916
## Installation
3017

docs/sdk/pnp/web/adapters/default-solana-adapter.mdx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,9 @@ description: "Web3Auth PnP Web Adapter SDKs - Default Solana Adapter | Documenta
99
import TabItem from "@theme/TabItem";
1010
import Tabs from "@theme/Tabs";
1111

12-
## [`@web3auth/default-solana-adapter`](https://npmjs.com/package/@web3auth/default-solana-adapter)
13-
14-
The default Solana adapter enables seamless detection of injected Solana wallets, allowing
15-
interaction with just a single line of code.
16-
17-
## Basic Details
18-
19-
#### Adapter Name: `default-solana-adapter`
20-
21-
#### Package Name: [`@web3auth/default-solana-adapter`](https://npmjs.com/package/@web3auth/default-solana-adapter)
22-
23-
#### authMode: `DAPP`
24-
25-
#### chainNamespace: `SOLANA`
26-
27-
#### Default: `NO`
12+
The [`@web3auth/default-solana-adapter`](https://npmjs.com/package/@web3auth/default-solana-adapter)
13+
package enables seamless detection of injected Solana wallets, allowing interaction with just a
14+
single line of code.
2815

2916
## Installation
3017

0 commit comments

Comments
 (0)