connect
Requests to connect Account(s) with optional capabilities.
Usage
import { } from './config'
const { } = await .() Returns
List of connected accounts.
type ReturnType = {
accounts: readonly {
address: Address
capabilities: Record<string, unknown>
}[]
}Parameters
capabilities
- Type:
Record<string, unknown>
Key-value pairs of capabilities.
import { } from './config'
const { } = await .({
: {
: {
: 1,
: 'abcd1234',
}
}
})Capabilities
unstable_addSubAccount
Adds a Sub Account to the connected Account. See more
// @filename: config.ts
import 'viem/window'
// ---cut---
import { createWalletClient, custom } from 'viem'
import { mainnet } from 'viem/chains'
import { erc7846Actions } from 'viem/experimental'
export const walletClient = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum!),
}).extend(erc7846Actions())
// @filename: example.ts
// ---cut---
import { walletClient } from './config'
const { accounts } = await walletClient.connect({
capabilities: {
unstable_addSubAccount: {
account: {
keys: [{
key: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
type: 'address',
}],
type: 'create',
}
}
}
})
}]
},
}],
address: '0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc',
unstable_subAccounts: [{
capabilities: {
address: '0x90F79bf6EB2c4f870365E785982E1f101E93b906',
[{
unstable_subAccounts
Returns all Sub Accounts of the connected Account. See more
import { } from './config'
const { } = await .()
}]unstable_signInWithEthereum
Authenticate offchain using Sign-In with Ethereum. See more
import { } from './config'
const { } = await .({
: {
: {
: 1,
: 'abcd1234',
}
}
})
}]JSON-RPC Methods
wallet_connect- Falls back to
eth_requestAccounts