Skip to content

candidelabs/7702-fireblocks-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EIP-7702 Account Abstraction with Fireblocks and Candide

This example demonstrates how to upgrade an EOA (Externally Owned Account) to a Smart Account using EIP-7702 delegation, with Fireblocks managing the signing and Candide providing the Account Abstraction infrastructure.

What This Example Does

  1. Creates a Fireblocks vault account and ETH wallet
  2. Upgrades the EOA to a Smart Account using EIP-7702 delegation
  3. Signs the EIP-7702 authorization with Fireblocks raw signing
  4. Creates a UserOperation to mint an NFT
  5. Uses a paymaster to sponsor gas fees (gasless transaction)
  6. Submits the UserOperation to the bundler for execution

What is EIP-7702?

EIP-7702 is a proposal that allows EOAs to temporarily delegate their code execution to a smart contract. This enables:

  • Smart Account features for regular wallets (multisig, social recovery, spending limits, etc.)
  • Gasless transactions via paymasters
  • Batch transactions (multiple operations in one)
  • Temporary delegation - the EOA can revert back anytime

Unlike smart contract wallets, EIP-7702 allows existing EOAs to gain smart account capabilities without migration.

Prerequisites

  • Node.js v18 or higher
  • Fireblocks account with API access
  • Candide account for bundler and paymaster access (Sign up here)
  • Ethereum RPC endpoint (Infura, Alchemy, or any Sepolia node)

Setup

1. Install Dependencies

npm install

2. Configure Environment Variables

Copy the .env.example file to .env and fill in your values:

cp .env.example .env

Then edit .env with your Fireblocks API credentials, Ethereum RPC endpoint, and Candide configuration.

3. Get Candide API Access

  1. Go to Candide Dashboard
  2. Create an account and project
  3. Get your Bundler URL from the project settings
  4. Get your Paymaster URL and create a Sponsorship Policy
  5. Add the policy ID to your .env file

4. Prepare Your Fireblocks Secret Key

Place your Fireblocks RSA private key file in this directory, or update FIREBLOCKS_SECRET_KEY_PATH to point to your key file.

Running the Example

npm start

Or with ts-node:

ts-node index.ts

How It Works

The example follows these steps:

Step 1: Create Vault and Wallet

Creates a new Fireblocks vault account and an ETH wallet (EOA) on Sepolia testnet.

Step 2: Initialize Smart Account

Creates a Simple7702Account instance and prepares an NFT mint transaction.

Step 3: Create UserOperation

Builds a UserOperation with the mint transaction and EIP-7702 authorization data.

Step 4: Sign EIP-7702 Authorization

Calculates the EIP-7702 delegation authorization hash and signs it with Fireblocks.

Step 5: Add Paymaster Sponsorship

Sends the UserOperation to Candide's paymaster to get gas sponsorship.

Step 6: Sign UserOperation

Creates the UserOperation hash, signs it with Fireblocks, and attaches the signature.

Step 7: Submit to Bundler

Sends the complete UserOperation to the bundler and waits for confirmation.

Key Code Snippets

EIP-7702 Authorization

const authHash = createEip7702DelegationAuthorizationHash(
    chainId,
    Simple7702Account.DEFAULT_DELEGATEE_ADDRESS,
    BigInt(nonce)
);

Fireblocks Raw Signing

const authTx = await signHash(
    fireblocks,
    vault.id,
    assetId,
    authHash.replace(/^0x/, ''),
);

UserOperation Structure

userOperation.eip7702Auth = {
    chainId: numberToHex(chainId),
    address: Simple7702Account.DEFAULT_DELEGATEE_ADDRESS,
    nonce: numberToHex(nonce),
    yParity: numberToHex(signature.v % 2),
    r: `0x${signature.r}`,
    s: `0x${signature.s}`,
};

Configuration Options

Supported Networks

This example runs on Sepolia testnet by default. To use other networks:

  1. Update CHAIN_ID in .env
  2. Update NODE_URL to the appropriate RPC endpoint
  3. Update BUNDLER_URL and PAYMASTER_URL for the target network
  4. Change the assetId in index.ts (e.g., ETH_TEST6 for Sepolia)
  5. Change viem chain import from sepolia to your target network
  6. Change the NFT minting on sepolia to a different transaction

Resources

Fireblocks

Candide

Account Abstraction

License

MIT

About

Upgrading Fireblocks EOAs to Smart Accounts (via EIP-7702)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published