Skip to content

Sign Authorize EIP-7702 (daccSignAuthorizeEIP7702)

A function to sign EIP-7702 authorization for smart contract delegation

The daccSignAuthorizeEIP7702 function allows you to sign EIP-7702 authorization from a Dacc wallet. This creates authorization signatures that allow smart contracts to control your wallet account using EIP-7702 delegation, enabling account abstraction features on externally owned accounts (EOA).

Import

import { daccSignAuthorizeEIP7702 } from 'dacc-js';

Usage

import { daccSignAuthorizeEIP7702 } from 'dacc-js';

import { optimismSepolia } from 'viem/chains'; // used `viem` - npm i viem
 
const result = await daccSignAuthorizeEIP7702({
  // account: "0xPrivatekey...", // Can call with `allowDaccWallet` function
  daccPublickey: 'daccPublickey_0x123_XxX..',
  // address: "0xYourAccountAddress..", // Only the address created is set to `publicEncryption: true`
  passwordSecretkey: 'my+Password#123..',
  network: optimismSepolia,
  contractAddress: '0xcontract...'
});
 
console.log(result); // {authorization, chainId, from, contractAddress}
console.log(result?.authorization); // EIP-7702 authorization signature

Arguments

ParameterTypeDescription
accountAccount or 0x${string}Conditional: The account to use for signing (Account object is private key).
daccPublickeystringConditional: The encrypted wallet data from createDaccWallet.
address0x${string}Conditional: wallet address from a created with createDaccWallet in publicEncryption: true mode (can use instead of daccPublickey).
passwordSecretkeystringConditional: The user's password used to decrypt the wallet.
networkChainThe blockchain network to use for signing.
contractAddress0x${string}The smart contract address to authorize for delegation.

Return Value

The response result is an object containing {authorization, chainId, from, contractAddress}

Parameters

account (conditional)

  • Type: Account | 0x${string}

The user's account to use for signing the authorization.

const result = await daccSignAuthorizeEIP7702({
  account: "0xPrivatekey...", 
//   address: '0x123...', //
//   daccPublickey: 'daccPublickey_0x123_XxX..', //
//   passwordSecretkey: 'my+Password#123..', //
  network: optimismSepolia,
  contractAddress: '0xcontract...'
});

daccPublickey (conditional)

  • Type: string

The user's encrypted public key to address.

daccPublickey is the most reliable addressing solution and supports all types of data storage using daccPublickey.

const result = await daccSignAuthorizeEIP7702({
//   account: "0xPrivatekey...", //
  daccPublickey: 'daccPublickey_0x123_XxX..', 
  passwordSecretkey: 'my+Password#123..', 
  network: optimismSepolia,
  contractAddress: '0xcontract...'
});

daccPublickey is the most reliable addressing solution and supports all types of data storage using daccPublickey.

address (optional)

  • Type: 0x${string}

The encrypted wallet data returned from createDaccWallet.

const result = await daccSignAuthorizeEIP7702({
//   account: "0xPrivatekey...", //
//   daccPublickey: 'daccPublickey_0x123_XxX..', // Match with address
  address: '0x123address...', // Only the address created is set to `publicEncryption: true`
  passwordSecretkey: 'my+Password#123..', 
  network: optimismSepolia,
  contractAddress: '0xcontract...'
});

passwordSecretkey (conditional)

  • Type: string

The same password used when creating the wallet.

const result = await daccSignAuthorizeEIP7702({
  daccPublickey: 'daccPublickey_0x123_XxX..',
  passwordSecretkey: 'my+Password#123..', 
  network: optimismSepolia,
  contractAddress: '0xcontract...'
});

network

  • Type: Chain

The blockchain network to use for signing.

const result = await daccSignAuthorizeEIP7702({
  daccPublickey: 'daccPublickey_0x123_XxX..',
  address: '0x123...',
  passwordSecretkey: 'my+Password#123..',
  network: optimismSepolia, 
  // network: myCustomChain, // For Custom Chain Network
  contractAddress: '0xcontract...'
});

contractAddress

  • Type: 0x${string}

The smart contract address to authorize for delegation.

const result = await daccSignAuthorizeEIP7702({
  daccPublickey: 'daccPublickey_0x123_XxX..',
  address: '0x123...',
  passwordSecretkey: 'my+Password#123..',
  network: optimismSepolia,
  contractAddress: '0xcontract...'
});

Examples

Basic EIP-7702 Authorization

const result = await daccSignAuthorizeEIP7702({
  daccPublickey: 'daccPublickey_0x123_XxX..',
  address: '0x123...',
  passwordSecretkey: 'my+Password#123..',
  network: optimismSepolia,
  contractAddress: '0xSmartWalletDelegate...'
});
 
console.log(`Authorization created for: ${result.contractAddress}`);
console.log(`From address: ${result.from}`);
console.log(`Chain ID: ${result.chainId}`);
console.log(`Authorization signature:`, result.authorization);

Using Account Parameter

const result = await daccSignAuthorizeEIP7702({
  account: "0xYourPrivateKey...",
  network: optimismSepolia,
  contractAddress: '0xAccountAbstractionContract...'
});
 
console.log(`EIP-7702 authorization signed successfully`);
console.log(`Authorization details:`, result.authorization);

Smart Wallet Delegation

import { optimismSepolia } from "viem/chains";
 
const smartWalletAuth = await daccSignAuthorizeEIP7702({
  daccPublickey: 'daccPublickey_0x123_XxX..',
  address: '0x123...',
  passwordSecretkey: 'my+Password#123..',
  network: optimismSepolia,
  contractAddress: '0xSmartWalletImplementation...'
});
 
// This authorization allows the smart contract to act on behalf of your EOA
console.log(`Smart wallet authorization:`, smartWalletAuth);
console.log(`Contract can now control address: ${smartWalletAuth.from}`);

Account Abstraction Setup

const aaAuth = await daccSignAuthorizeEIP7702({
  daccPublickey: 'daccPublickey_0x123_XxX..',
  address: '0x123...',
  passwordSecretkey: 'my+Password#123..',
  network: optimismSepolia,
  contractAddress: '0xAccountAbstractionWallet...'
});
 
// Now your EOA can use account abstraction features like:
// - Batched transactions
// - Gas sponsorship 
// - Custom validation logic
 
console.log(`Account abstraction enabled for: ${aaAuth.from}`);
console.log(`AA Contract: ${aaAuth.contractAddress}`);