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.
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.

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

Configure an account signatory

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

import { publicClient } from "./client.ts"
import { signatory } from "./signatory.ts";
import {
Implementation,
toMetaMaskSmartAccount,
} from "@metamask-private/delegator-core-viem";

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

Configure a Wallet Client signatory

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

import { publicClient } from "./client.ts"
import { signatory } from "./signatory.ts";
import {
Implementation,
toMetaMaskSmartAccount,
} from "@metamask-private/delegator-core-viem";

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

Configure a WebAuthn (passkey) signatory

This example uses Viem's toWebAuthnAccount function to create a WebAuthnAccount as the signatory.

import { publicClient } from "./client.ts"
import { signatory } from "./signatory.ts";
import {
Implementation,
toMetaMaskSmartAccount,
} from "@metamask-private/delegator-core-viem";

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

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.

Configure signatories

For a Multisig Delegator, you can use a combination of account signatories and Wallet Client signatories. For example:

import { publiClient } from "./client.ts";
import { account, walletClient } from "./signers.ts";
import {
Implementation,
toMetaMaskSmartAccount,
} from "@metamask-private/delegator-core-viem";

const signers = [ account.address, walletClient.address ];
const signatory = { account, walletClient };
const threshold = 2n

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

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