addSubAccount
Requests to add a Sub Account. See more
Usage
example.ts
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
keys: [{
publicKey: '0xefd5fb29a274ea6682673d8b3caa9263e936d48d',
type: 'address'
}],
type: 'create',
})
Returns
The created Sub Account.
type ReturnType = {
address: Address
factory?: Address | undefined
factoryData?: Hex | undefined
}
Parameters
New Accounts
Allows the wallet to create a Sub Account with a set of known signing keys. Learn more
keys
Set of signing keys that will belong to the Sub Account.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
keys: [{
publicKey: '0xefd5fb29a274ea6682673d8b3caa9263e936d48d486e5df68893003e01241522',
type: 'p256'
}],
type: 'create',
})
keys.publicKey
- Type:
Hex
The public key of the signing key.
- This is a 32-byte hexadecimal string.
- For
type: "address"
, this is a 20-byte address.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
keys: [{
publicKey: '0xefd5fb29a274ea6682673d8b3caa9263e936d48d486e5df68893003e01241522',
type: 'p256'
}],
type: 'create',
})
keys.type
- Type:
'address' | 'p256' | 'webcrypto-p256' | 'webauthn-p256'
The type of signing key.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
keys: [{
publicKey: '0xefd5fb29a274ea6682673d8b3caa9263e936d48d486e5df68893003e01241522',
type: 'p256'
}],
type: 'create',
})
Deployed Accounts
An existing account that the user wants to link to their global account. Learn more
address
Address of the deployed account.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
address: '0x0000000000000000000000000000000000000000',
type: 'deployed',
})
chainId
The chain ID of the deployed account.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
address: '0x0000000000000000000000000000000000000000',
chainId: 1,
type: 'deployed',
})
Undeployed Accounts
An account that has been created, but is not yet deployed. The wallet will decide whether or not to deploy it. Learn more
address
Address of the undeployed account.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
address: '0x0000000000000000000000000000000000000000',
factory: '0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce',
factoryData: '0xdeadbeef',
type: 'undeployed',
})
chainId
The chain ID the account will be deployed on.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
address: '0x0000000000000000000000000000000000000000',
chainId: 1,
factory: '0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce',
factoryData: '0xdeadbeef',
type: 'undeployed',
})
factory
The address of the factory contract.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
address: '0x0000000000000000000000000000000000000000',
factory: '0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce',
factoryData: '0xdeadbeef',
type: 'undeployed',
})
factoryData
The data to be passed to the factory contract.
import { walletClient } from './config'
const subAccount = await walletClient.addSubAccount({
address: '0x0000000000000000000000000000000000000000',
factory: '0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce',
factoryData: '0xdeadbeef',
type: 'undeployed',
})