-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add app accounts sdk docs #1820
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# App Accounts | ||
|
||
App Accounts enable developers to create and manage app-specific accounts for their applications. These accounts are linked to the user's Smart Wallet and can be utilized to sign transactions specifically for the app. This integration grants developers full control over the user experience, ensuring a seamless and cohesive interaction within the app. | ||
|
||
## Technical Details | ||
|
||
- Smart Wallet Ownership: The user's Smart Wallet acts as an owner of the app account, allowing it to manage and control the app-specific account. | ||
- Key Agnostic: App Accounts are designed to be key agnostic. They leverage our Linked Accounts technology, which supports various key types including in-browser CryptoKeys, Passkeys, and server signer products. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need a page on different signers types, and the reasons why you as a developer might want to use different ones based your app's use case |
||
- App Accounts can be used to sign transactions, messages, and EIP-712 typed data. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# App Accounts | ||
|
||
App Accounts enable developers to create and manage app-specific accounts for their applications. These accounts are linked to the user's Smart Wallet and can be utilized to sign transactions specifically for the app. This integration grants developers full control over the user experience, ensuring a seamless and cohesive interaction within the app. | ||
|
||
App Accounts can be interacted with via the Coinbase Wallet SDK. | ||
|
||
## How it works | ||
|
||
1. An application can create an app account for a user by using the `wallet_addAccount` RPC method. See [EIP-XXXX](https://eips.ethereum.org/EIPS/eip-XXXX) for more details. | ||
2. The application can either create the account themselves or provide a signer for the Smart Wallet to create the account. | ||
3. Once the account is created, the application can use the account to sign transactions, messages, and EIP-712 typed data. | ||
|
||
## Example (creating a new app account) | ||
|
||
```typescript | ||
import { createCoinbaseWalletSDK } from '@coinbase/coinbase-sdk'; | ||
import { privateKeyToAccount } from 'viem/accounts'; | ||
|
||
const sdk = new createCoinbaseWalletSDK({ | ||
appName: 'My App', | ||
appLogoUrl: 'https://myapp.com/logo.png', | ||
appChainIds: [84532], | ||
subAccount: { | ||
getSigner: async () => { | ||
return privateKeyToAccount('0x...'); | ||
}, | ||
}, | ||
}); | ||
|
||
const provider = sdk.getProvider(); | ||
|
||
const response = await provider.request({ | ||
method: 'wallet_addAccount', | ||
params: [ | ||
{ | ||
version: 1, | ||
account: { | ||
signers: [ | ||
{ | ||
type: 'key', | ||
data: { | ||
publicKey: '0x...', | ||
type: 'secp256k1', | ||
}, | ||
}, | ||
{ | ||
type: 'account', | ||
data: { | ||
address: '0x...', | ||
}, | ||
Comment on lines
+47
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. based on what's being passed to |
||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}); | ||
``` | ||
|
||
## Example (using an existing app account) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using an existing and deployed app account |
||
|
||
```typescript | ||
const sdk = new createCoinbaseWalletSDK({ | ||
appName: 'My App', | ||
appLogoUrl: 'https://myapp.com/logo.png', | ||
appChainIds: [84532], | ||
subAccount: { | ||
getSigner: async () => { | ||
return privateKeyToAccount('0x...'); | ||
}, | ||
}, | ||
}); | ||
|
||
const provider = sdk.getProvider(); | ||
|
||
const response = await provider.request({ | ||
method: 'wallet_addAccount', | ||
params: [ | ||
{ | ||
version: 1, | ||
account: { | ||
address: '0x...', | ||
}, | ||
}, | ||
], | ||
}); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Linked Accounts technology" to be eventually replaced with EIP-XXXX?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including, but not limited to, in-browser CryptoKeys, Passkeys, traditional EOAs, and server wallets products.