zkSync Transaction Simulations

A practical guide to Building a Minimal Account Abstraction Contract on zkSync Era: System Calls and Simulations - Construct `ZkMinimalAccount.sol` on zkSync Era, implementing the `validateTransaction` logic for nonce increments and signature checks. Navigate zkSync's unique "System Contract Calls" and "Simulations" using `SystemContractsCaller` and the `--system-mode` flag to manage nonces via `NonceHolder`.

Solidity Developer

Advanced Foundry

1. Introduction
An essential guide to Understanding Account Abstraction - Explore how Account Abstraction is revolutionizing Web3 by enabling programmable smart contract wallets, moving beyond traditional private key limitations. This lesson delves into Ethereum's EIP-4337, its components like UserOps and Bundlers, and contrasts it with native AA solutions like zkSync. Duration: 11min
2. Code Overview
An enlightening exploration of Account Abstraction: The Future of Web3 Wallets on Ethereum & zkSync - Discover how smart contract wallets are reshaping user experience, comparing Ethereum's ERC-4337 (EntryPoint, Bundlers) with zkSync's native AA (Bootloader). Learn from minimal examples to unlock custom transaction logic and advanced features. Duration: 4min
3. Ethereum Setup
A foundational setup guide to Setting Up Your Account Abstraction Project - Initialize your Foundry project, structure directories for Ethereum ERC-4337 and zkSync AA wallets, and create your first `MinimalAccount.sol`. You'll install ERC-4337 dependencies and implement the `IAccount` interface by stubbing `validateUserOp`. Duration: 10min
4. PackedUserOperation
A deep-dive exploration to Understanding the PackedUserOperation Struct for Account Abstraction - Journey through each field of ERC-4337's `PackedUserOperation`, from `sender` to `signature`, and grasp their individual roles. Understand how this vital struct underpins account abstraction by enabling secure and flexible transaction handling by smart contract wallets. Duration: 2min
5. Validate UserOp
A crucial deep dive to ERC-4337 `validateUserOp`: Signature Validation with `Ownable` - Implement the core signature validation logic within `validateUserOp` for ERC-4337 smart contract accounts. You'll use OpenZeppelin's `Ownable` for owner-based authorization and `ECDSA` for secure signature verification. Duration: 15min
6. EntryPoint Contract
An in-depth security enhancement to Refining Smart Account EntryPoint Security - Solidify your ERC-4337 `MinimalAccount` by restricting `validateUserOp` to the EntryPoint contract using constructor initialization and an `IEntryPoint` interface. You'll learn to implement and apply a custom modifier for robust, EntryPoint-only access. Duration: 3min
7. Execute Function Ethereum
A developer's guide to Activating Smart Contract Accounts: The ERC-4337 `execute` Function - Unlock the power of your ERC-4337 smart contract account by implementing the `execute` function, enabling it to call other contracts and manage its own Ether. This lesson details low-level call mechanics, the `requireFromEntryPointOrOwner` modifier for security, the `receive` function for funding, and best practices with custom errors. Duration: 8min
8. Deployment Script for an Ethereum Account
A constructive walkthrough to Building Your ERC-4337 Deployment Foundation - Establish core Foundry deployment scripts (`DeployMinimal.s.sol`, `HelperConfig.s.sol`) for an ERC-4337 `MinimalAccount` contract. Learn to manage multi-chain `EntryPoint` configurations with `HelperConfig`, preparing for robust account abstraction deployments. Duration: 12min
9. Test Owner can Execute
A foundational guide to Testing MinimalAccount Owner Execution with Foundry - Set up robust Foundry tests for `MinimalAccount.sol`, using `vm.prank` and mock contracts to verify owner `execute` capabilities. Solidify access control by ensuring non-owner attempts correctly revert with `vm.expectRevert`. Duration: 13min
10. Unsigned PackedUserOperation Test
An essential coding tutorial to Crafting an Unsigned PackedUserOperation for ERC-4337 - Learn to code a Foundry script that generates an unsigned `PackedUserOperation`, crucial for ERC-4337. This lesson covers populating key fields like `sender`, `nonce` (using `vm.getNonce`), `callData`, and packing gas parameters, preparing the operation for later signing. Duration: 11min
11. Signed UserOp Test
A practical guide to Correctly Signing ERC-4337 UserOperations for the EntryPoint - Learn to generate the precise `userOpHash` for ERC-4337 `EntryPoint` interactions and create EIP-191 compliant signatures for `PackedUserOperations`. You'll deploy mock `EntryPoints`, use `vm.sign` in Foundry, handle test signing, and verify signatures for reliable ERC-4337 development. Duration: 23min
12. Quiz 12 Quiz
Questions: 8
13. Local Dev Unlocked
A practical refactoring guide to Streamlining UserOperation Signing for Local and Testnet Development - Master conditional ERC-4337 UserOperation signing in Foundry, using Anvil's default key locally and configured keys on testnets. You'll implement `vm.sign` with `block.chainId` checks and update `HelperConfig` for consistency. Duration: 4min
14. Test Validate UserOps
An indispensable security walkthrough to Testing User Operation Validation in Your Smart Contract Account - Bolster your ERC-4337 smart account's security by mastering the `testValidationOfUserOps` test, ensuring correct validation of EntryPoint-invoked user operations. You'll practice signing user ops, simulating EntryPoint calls via `vm.prank`, and asserting expected validation results. Duration: 5min
15. Test EntryPoint
An advanced tutorial to Mastering EntryPoint Execution for ERC-4337 UserOperations - Unlock the "crazy skill" of verifying `EntryPoint` execution of UserOperations in ERC-4337. You'll set up tests for `handleOps`, fund smart accounts for bundler compensation, and diagnose an EVM revert, deepening your Account Abstraction expertise. Duration: 6min
16. Advanced Debugging
A hands-on guide to Debugging ERC-4337 UserOperations in Foundry - Troubleshoot failing ERC-4337 tests by mastering Foundry's debugger to fix `UserOperation` `sender` and `nonce` errors. You'll use `Shift + G` to locate reverts, step through EVM opcodes, and ensure your smart contract accounts behave as expected. Duration: 5min
17. Mid Session Recap
A vital recap to Unpacking Account Abstraction on Ethereum and zkSync - Reinforce your understanding of Ethereum's EIP-4337, including UserOperations, Bundlers, and the EntryPoint contract. Then, explore zkSync's native Account Abstraction, contrasting its streamlined Type 113 transaction flow and simplified architecture. Duration: 4min
18. Quiz 18 Quiz
Questions: 8
19. Live Demo on Arbitrum
An illustrative guide to Deploying an ERC-4337 Smart Account and Sending a UserOperation on Arbitrum - Follow the deployment of an ERC-4337 `MinimalAccount` to Arbitrum using Foundry, then craft and send a `UserOperation`. This lesson walks through constructing calldata for contract interactions and verifying the entire flow on Arbiscan. Duration: 8min
20. zkSync Setup
A foundational guide to Understanding zkSync Native Account Abstraction: Setup and Core Concepts - Dive into zkSync's native Account Abstraction, contrasting its advantages like no alt-mempool with ERC-4337, and learn how all accounts are smart contracts. You'll install `foundry-era-contracts` and begin building a `ZkMinimalAccount.sol` by implementing the `IAccount` interface. Duration: 9min
21. Iaccount
A detailed primer to Understanding the `IAccount` Interface in ZK Sync - Explore ZK Sync's native Account Abstraction via the IAccount interface, comparing it to EIP-4337 and dissecting the core Transaction struct. Learn how functions like `validateTransaction`, `executeTransaction`, and paymaster interactions empower smart accounts. Duration: 8min
22. System Contracts
An essential primer to Unpacking zkSync: How Transactions and System Contracts Work - Delve into zkSync's two-phase transaction model (validation and execution) and the key functions of system contracts such as NonceHolder and ContractDeployer. Understand how this architecture handles nonces and deploys contracts differently from Ethereum, affecting tools like Foundry. Duration: 4min
23. Type 113 Lifecycle
A clarifying exploration to Unpacking the zkSync TxType 113 Account Abstraction Lifecycle - Discover the two-phase (Validation and Execution) process for native account abstraction (TxType 113) on zkSync. You'll understand the vital roles of the Bootloader, `NonceHolder`, and the key `IAccount` methods `validateTransaction` and `executeTransaction`. Duration: 7min
24. zkSync Accounts Recap
A foundational guide to zkSync Era's Native Account Abstraction - Discover how smart contracts become primary accounts through zkSync Era's native AA and Type 113 transactions. Learn the roles of the Bootloader, NonceHolder, the transaction lifecycle, and how gas fees are managed. Duration: 3min
25. Quiz 25 Quiz
Questions: 6
26. zkSync Transaction Simulations
A practical guide to Building a Minimal Account Abstraction Contract on zkSync Era: System Calls and Simulations - Construct `ZkMinimalAccount.sol` on zkSync Era, implementing the `validateTransaction` logic for nonce increments and signature checks. Navigate zkSync's unique "System Contract Calls" and "Simulations" using `SystemContractsCaller` and the `--system-mode` flag to manage nonces via `NonceHolder`. Duration: 14min
27. Validate Transaction zkSync
A comprehensive guide to Deep Dive: The `validateTransaction` Function in `ZkMinimalAccount.sol` - Learn the intricacies of zkSync Era's `validateTransaction`, covering nonce management, fee validation, and signature verification. Understand its role in account abstraction, including bootloader access control and magic return values. Duration: 12min
28. Execute Function zkSync
A practical examination to Deep Dive: The `executeTransaction` Function in zkSync Smart Accounts - Explore the `executeTransaction` function's role in zkSync smart accounts, covering how it handles validated transactions by extracting parameters and ensuring type safety. You'll implement calls to system contracts using `SystemContractsCaller`, external calls via assembly, and secure the function with access control modifiers. Duration: 9min
29. Pay For Transaction zkSync
A vital lesson to Implementing Fee Payment in zkSync Native Account Abstraction - Implement the `payForTransaction` function, empowering your zkSync native account to manage its own transaction fees. You'll also explore `prepareForPaymaster`, zkSync's distinct pre-execution payment mechanism, and the `payToTheBootloader` helper. Duration: 3min
30. Execute Transaction From Outside
A refactoring masterclass for Implementing External Transaction Execution in Your zkSync AA Contract - Discover how to enable third-party transaction relay and gas payment by adding `executeTransactionFromOutside` to your zkSync AA contract. This lesson thoroughly details refactoring common validation and execution logic into internal helper functions for cleaner, more reusable code. Duration: 8min
31. zkSync Tests
A foundational guide to Setting Up Your zkSync AA Test Environment with Foundry - Learn to establish your Foundry project for zkSync native Account Abstraction tests, including directory structure, initial test files, and boilerplate for `ZkMinimalAccount`. This lesson also contrasts zkSync's native AA mechanics with Ethereum's ERC-4337. Duration: 6min
32. Transaction Struct
A developer's deep-dive to zkSync Transaction Structs for Smart Account Foundry Tests - Explore building the zkSync `Transaction` struct with a helper function in Foundry, vital for smart contract account testing. Master its fields, address casting, nonce handling, and execute owner-initiated transactions via `executeTransaction`. Duration: 9min
33. Via Ir
A crucial deep-dive to Mastering Solidity's "Stack Too Deep" Error via Foundry's IR Pipeline - Learn why the "stack too deep" error plagues complex Solidity contracts, especially with zkSync, and how to resolve it by enabling the via-IR compiler option in your `foundry.toml`. This lesson details the fix and applies it to a zkSync account abstraction test. Duration: 2min
34. Validate Transaction Test
An essential guide to Validating zkSync AA Transactions in Foundry - Master testing the `validateTransaction` function for zkSync Account Abstraction contracts, focusing on signature verification and the `ACCOUNT_VALIDATION_SUCCESS_MAGIC` return. You'll configure Foundry with `--zksync` and `--system-mode`, use `vm.prank` for Bootloader simulation, and `vm.sign` for test signatures. Duration: 14min
35. Clean Up zkSync
A comprehensive guide to Mastering zkSync Account Abstraction: Testing and Lifecycle Deep Dive - Consolidate your understanding by testing core zkSync AA functions like `validateTransaction` and `executeTransaction`. Explore the detailed zkSync transaction lifecycle and master Foundry test execution using zkSync-specific flags for accurate simulation. Duration: 3min
36. Testnet zkSync Demo
An essential guide to Deploying and Interacting with Account Abstraction on zkSync - Deploy your first Account Abstraction contract on zkSync using Hardhat and initiate transactions as the contract itself. Learn vital smart contract adjustments for correct EIP-712 signature validation and secure transaction execution via magic value checks. Duration: 5min
37. Recap End
An enlightening exploration to Understanding Account Abstraction: A Comprehensive Guide - Uncover the power of Account Abstraction, transforming user accounts into programmable smart contracts for better UX and security. Compare the ERC-4337 standard on EVM chains with native AA solutions like zkSync, detailing their distinct workflows and components. Duration: 8min
38. Quiz 39 Quiz
Questions: 11

Course Overview

About the course

What you'll learn

Advanced smart contract development

How to develop a stablecoin

How to develop a DeFi protocol

How to develop a DAO

Advanced smart contracts testing

Fuzz testing

Manual verification

Course Description

Who is this course for?

  • Engineers
  • Smart Contract Security researchers

Potential Careers

Web3 Developer Relations

$85,000 - $125,000 (avg. salary)

Web3 developer

$60,000 - $150,000 (avg. salary)

Smart Contract Engineer

$100,000 - $150,000 (avg. salary)

Smart Contract Auditor

$100,000 - $200,000 (avg. salary)

Security researcher

$49,999 - $120,000 (avg. salary)

Meet your instructors

Patrick Collins

Patrick Collins

Founder at Cyfrin

Web3 engineer, educator, and Cyfrin co-founder. Patrick's smart contract development and security courses have helped hundreds of thousands of engineers kickstarting their careers into web3.

Guest lecturers:

Juliette Chevalier

Juliette Chevalier

Lead Developer relations at Aragon

Ciara Nightingale

Ciara Nightingale

Developer relations at Cyfrin

Vasiliy Gualoto

Vasiliy Gualoto

Developer relations at ThirdWeb

Nader Dabit

Nader Dabit

Director of developer relations at EigenLayer

Ally Haire

Ally Haire

Developer relations at Protocol Labs

Harrison

Harrison

Founder at GasliteGG

Vitto Rivabella

Vitto Rivabella

CPO at Cyfrin

Last updated on May 12, 2025