Skip to main content

Configure accounts and signers

The Delegation Toolkit supports different delegator accounts types, each with its own configuration and support for different signing mechanisms. You can create flexible and secure delegator accounts tailored to your specific needs.

Configure a Hybrid Delegator

The Hybrid Delegator supports both an EOA "owner" and any number of P256 (passkey) signers.

To configure a Hybrid Delegator, provide the following parameters:

  • owner: The owner's account address as a hex string. The owner can be the zero address, indicating that there is no owner configured.
  • p256KeyIds: An array of key identifiers for P256 signers as hex strings.
  • p256XValues: An array of public key x-values for P256 signers as bigints.
  • p256YValues: An array of public key y-values for P256 signers as bigints.
  • signatory: A signer that will sign on behalf of the delegator account.

Example configuration:

const smartAccount = await toMetaMaskSmartAccount({
client,
implementation: Implementation.Hybrid,
deployParams: [owner, p256KeyIds, p256XValues, p256YValues],
deploySalt: "0x",
signatory,
});
note

You can set all p256 parameters to empty arrays to configure no WebAuthn signer. However, we recommend configuring at least one signer for account recoverability.

Configure the signatory

For a Hybrid Delegator, you can configure the following types of signatories:

  • Account signatory (EOA):

    This example uses Viem's privateKeyToAccount function to create a signatory from a private key.

    const account = privateKeyToAccount(PRIVATE_KEY);

    const signatory = { account };
  • Wallet Client signatory:

    This example uses Viem's createWalletClient function to create a Wallet Client as the signatory.

    const walletClient = createWalletClient({...});

    const signatory = { walletClient };
  • WebAuthn (passkey) signatory:

    import { createCredential, parsePublicKey } from "webauthn-p256";
    import { toWebAuthnAccount } from "viem/account-abstraction";
    import { toHex } from "viem";

    const credential = await createCredential({ name: "Your Delegator Passkey" });
    const webAuthnAccount = toWebAuthnAccount({ credential });
    const keyId = toHex("my-key-id");

    const webAuthnSignatory = { webAuthnAccount, keyId };

Configure a Multisig Delegator

The Multisig Delegator supports multiple EOA signers with a configurable threshold for execution.

To configure a Multisig Delegator, provide the following parameters:

  • signers: An array of EOA signer addresses as hex strings.
  • threshold: The number of signers required to execute a transaction, as a bigint.
  • signatory: An array of signatories that will sign on behalf of the delegator account.

Example configuration:

const smartAccount = await toMetaMaskSmartAccount({
client,
implementation: Implementation.MultiSig,
deployParams: [signers, threshold],
deploySalt: "0x",
signatory,
});

Configure the signatory

For a Multisig Delegator, you can use a combination of Account signatories and Wallet Client signatories:

const account = privateKeyToAccount(PRIVATE_KEY);
const walletClient = createWalletClient({...});

const signatory = [
{ account },
{ walletClient }
];

const signers = [ account.address, walletClient.address ];
const threshold = 2n;
note

The number of signers in the signatories must be at least equal to the threshold for valid signature generation.