Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • TRADING
  • SUBMIT
Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • TRADING
  • SUBMIT
Crypto Flexs
Home»HACKING NEWS»Test proxy contracts securely using Wake Framework
HACKING NEWS

Test proxy contracts securely using Wake Framework

By Crypto FlexsDecember 30, 20254 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Test proxy contracts securely using Wake Framework
Share
Facebook Twitter LinkedIn Pinterest Email

introduction

Upgrades are where production bugs hide: missing initialization, bad administrator, or corrupted repositories. The proxy pattern allows contracts to be upgraded, but introduces complexity that traditional testing misses. Wake’s Python-first testing catches these issues before they reach mainnet.

The result is clean test code. Calling an implementation function through a proxy is straightforward.

contract = ExampleERC20Upgradeable(proxy)

Here’s how to test proxy contracts in Wake:

1. Import proxy contract

Wake needs to compile proxy contracts to generate Python type bindings (pytypes). If the proxy contract is in the library directory, Wake will not compile it by default.

in wake.tomlThe default configuration is as follows: exclude_paths = ("script", ".venv", "venv", "node_modules", "lib", "test"). This means that contracts in these paths will not be compiled unless they are imported from a non-excluded file.

To make a contract available to your project, import the contract externally. exclude_paths. Please refer to the documentation for more details: https://ackee.xyz/wake/docs/latest/compilation/

make tests/imports.sol To enable pytype:

import ERC1967Proxy from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

2. Import proxy in Python

run wake up Compile again. Wake generates Python bindings for both implementation and proxy contracts. Import it as a test file.

tests/test_upgradable.py

from pytypes.contracts.ExampleERC20Upgradeable import ExampleERC20Upgradeable
from pytypes.openzeppelin.contracts.proxy.ERC1967.ERC1967Proxy import ERC1967Proxy

3. Deployment and initialization

First deploy the implementation contract and then create a proxy pointing to it. The proxy’s initialization data encodes a call to the implementation’s ‘init’ function.

@chain.connect()
@on_revert(revert_handler)
def test_default():

    impl_erc20 = ExampleERC20Upgradeable.deploy()

    proxy = ERC1967Proxy.deploy(
        implementation =impl_erc20,
        _data=abi.encode_call(ExampleERC20Upgradeable.initialize, ("Upgradable Token", "UPG", 10**20, chain.accounts(0))),
        from_=chain.accounts(0)
    )

The `_data` parameter encodes the initialization call that is executed during proxy deployment. This replaces the constructor pattern used for non-upgradable contracts.

4. Access implementation functions through proxy

Wrap the proxy address with an implementation contract class. This instructs Wake to route all function calls through the proxy while using the implementation’s ABI.

contract = ExampleERC20Upgradeable(proxy)

Wake automatically handles routing of delegate calls, allowing you to interact with the contract as if it were a simple deployment.

5. Call implementation function

All implementation features are now available through the wrapped proxy. You can check the behavior of your contracts, inspect events, and test state changes.

# Verify initial balance
assert contract.balanceOf(chain.accounts(1)) == 0

# Execute transfer
tx = contract.transfer(chain.accounts(1), 10**18, from_=chain.accounts(0))

# Inspect emitted events
event = next(event for event in tx.events if isinstance(event, ExampleERC20Upgradeable.Transfer))
assert event.from_ == chain.accounts(0).address
assert event.to == chain.accounts(1).address
assert event.value == 10**18

# Verify updated balance
assert contract.balanceOf(chain.accounts(1)) == 10**18

Tests verify that the proxy delegates correctly to the implementation and maintains state as expected.

conclusion

Wake simplifies proxy testing through Python bindings. Wrap the proxy address in an implementation class and call the function directly. The same approach also works for unit testing and Manually Guided Fuzzing (MGF), so you can test upgradeable contracts using the same tools you use for standard contracts.

This catches upgrade bugs (missed initializations, storage conflicts, access control issues) before they can be exploited. Test proxy patterns the same way you test everything else.

Learn more here. See our beginner’s guide to manually guided fuzzing.

Appendix: Full test code

import math
from wake.testing import *
from dataclasses import dataclass

from pytypes.contracts.ExampleERC20Upgradeable import ExampleERC20Upgradeable
from pytypes.openzeppelin.contracts.proxy.ERC1967.ERC1967Proxy import ERC1967Proxy

# Print failing tx call trace
def revert_handler(e: RevertError):
    if e.tx is not None:
        print(e.tx.call_trace)

@chain.connect()
@on_revert(revert_handler)
def test_default():

    impl_erc20 = ExampleERC20Upgradeable.deploy()

    proxy = ERC1967Proxy.deploy(
        implementation =impl_erc20,
        _data=abi.encode_call(ExampleERC20Upgradeable.initialize, ("Upgradable Token", "UPG", 10**20, chain.accounts(0))),
        from_=chain.accounts(0)
    )

    contract = ExampleERC20Upgradeable(proxy) # Just wrap the proxy with the contract Class to call functions

    assert contract.balanceOf(chain.accounts(1)) == 0
    tx = contract.transfer(chain.accounts(1), 10**18, from_=chain.accounts(0))

    event = next(event for event in tx.events if isinstance(event, ExampleERC20Upgradeable.Transfer))
    assert event.from_ == chain.accounts(0).address
    assert event.to == chain.accounts(1).address
    assert event.value == 10**18

    assert contract.balanceOf(chain.accounts(1)) == 10**18

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

Related Posts

Cryptocurrency Inheritance Update: June 2025

May 7, 2026

Guardian Rewards – Vault12

May 1, 2026

Cryptocurrency Inheritance Update: March 2026

April 9, 2026
Add A Comment

Comments are closed.

Recent Posts

Swan Bitcoin faces nearly $1 billion lawsuit related to Prime Trust transfers

May 19, 2026

$100/Month In Bitcoin Since 2015 Would Have Turned $13,700 Into $632,000, Coinbird Analysis Shows

May 19, 2026

MEXC Reports Sharp Surge In TradFi Futures Trading Volume In April, Led By 1,600% Jump In INTC

May 19, 2026

Urban Run” Game With Up To 1 BTC In Rewards

May 19, 2026

Bitmine Immersion Technologies (BMNR) Announces ETH Holdings Reach 5.28 Million Tokens, And Total Crypto And Total Cash Holdings Of $12.6 Billion

May 18, 2026

How to Bet Safely with Crypto: The Most Trusted Licensed Sportsbook

May 18, 2026

Lock.com Enters Early Access With Isolated Signing And Post-Quantum Architecture

May 18, 2026

1win Crypto Tournaments Go Global With Up To 200K USDT In Rewards

May 18, 2026

Ethereum Triangle Breakdown Adds Pressure to Recovery Prospects

May 18, 2026

AFX Launches Sovereign Layer 1, Providing An Optimized Execution Environment For On-chain Perp DEXes

May 18, 2026

DOGEBALL Tracks 2900% Profits, Breaks Poly Truth Capital, Meme Punch Stagnation, Positions itself as Best Cryptocurrency Presale to Buy Now

May 18, 2026

Crypto Flexs is a Professional Cryptocurrency News Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of Cryptocurrency. We hope you enjoy our Cryptocurrency News as much as we enjoy offering them to you.

Contact Us : Partner(@)Cryptoflexs.com

Top Insights

Swan Bitcoin faces nearly $1 billion lawsuit related to Prime Trust transfers

May 19, 2026

$100/Month In Bitcoin Since 2015 Would Have Turned $13,700 Into $632,000, Coinbird Analysis Shows

May 19, 2026

MEXC Reports Sharp Surge In TradFi Futures Trading Volume In April, Led By 1,600% Jump In INTC

May 19, 2026
Most Popular

BNB Chain solves BscScan delay issue, opBNB is still being fixed.

December 18, 2023

Integrity Guarantee: Protect LLM Tokenizers from Potential Threats

June 28, 2024

Solana (SOL) has three reasons for the 50% drop in history

February 25, 2025
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions
© 2026 Crypto Flexs

Type above and press Enter to search. Press Esc to cancel.