Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-7613 proposes a minimal proxy called a Puppet. When its deployer calls it, the Puppet can use an address supplied in calldata as the target of a delegatecall. The deployer can change the execution logic without changing the Puppet itself.

This article explains the proposal below.

I also cover EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.

Overview

A Puppet normally behaves like an empty account, much like an externally owned account (EOA) when called. It does nothing and exposes no public function interface.

The exception is a call from the deployer. If that call supplies a valid target address in its input, the Puppet performs a delegatecall to the target.

  • Call data (calldata) is the input supplied with a contract call. It typically encodes the function to call and its arguments.
  • delegatecall executes code from another contract in the calling contract's context. In this case the execution uses the Puppet's address, storage, and balance context.

The deployer can therefore execute different logic using the Puppet's state and assets. The Puppet remains small and fixed while the deployer chooses where its execution logic lives.

Motivation

Using a Puppet as a separate account

A Puppet has its own address and balance. A deployer can use it as a separate account, for example to assign each user of a protocol a dedicated deposit address.

  1. A user calls the protocol contract.
  2. The protocol deploys a Puppet and associates its address with the user.
  3. The protocol treats the assets sent to that Puppet as the user's deposits.
  4. To withdraw or move those assets, the protocol calls the Puppet and directs it to delegate to the transfer logic.

CREATE2 makes advance address calculation possible. Its deployment address depends on the deployer, the salt, and the hash of the creation code. With fixed creation code and a user address encoded as the salt, the protocol can predict that user's Puppet address. Assets can be sent to that address before the Puppet is deployed. The protocol later deploys it and attributes the deposited assets to the user.

Depositing without approve

Many DeFi protocols take deposits through an ERC-20 approve followed by the protocol's transferFrom. This adds approval management and a separate step for the user.

A Puppet allows deposits via an ordinary transfer to an address allocated to the user. The user does not need to approve the protocol or call it to make that transfer.

  • Deposits can arrive through multiple transactions or from multiple sources.
  • Funds can come from another protocol with no additional integration if it can transfer to an arbitrary address.
  • A wallet that supports only ordinary ERC-20 transfers can still deposit.
  • Users of more capable wallets can use a familiar transfer flow and avoid signing unfamiliar calldata for the deposit.
  • Someone still needs to notify the protocol after the transfer if the protocol requires it. The design may let the user or a third party do this.

See the following article for background on ERC-20.

[ERC20] An introduction to ERC-20

  • Gasless transactions are transactions for which another party, such as a relayer, pays the fee on behalf of the user.

Puppets suit protocols that can define or preconfigure what happens after a deposit. The proposal argues that many protocols that use approval-based deposits could benefit from this arrangement.

Updating behavior without upgrading each Puppet

The Puppet's own logic is fixed. The deployer can change its behavior by supplying a different delegatecall address or different call data.

A deployer contract that controls many Puppets can update the logic it directs them to use. This lets it coordinate updates across those Puppets without placing a beacon in each one.

  • A beacon is a contract that records a shared implementation address. Many proxies can read that address so an update applies to all of them.

The deployer can also point a Puppet at the address that holds the deployer's own logic. This keeps the logic used by the Puppets within the deployer's implementation.

Callers other than the deployer have no direct API

A third party cannot ask a Puppet to execute logic directly. To support an operation initiated by a third party, the deployer must expose a function that calls the Puppet on the third party's behalf.

This makes Puppets unsuitable as direct recipients when a protocol expects the recipient contract to implement a particular callback. For example, an ERC-721 safe transfer to a contract expects a receiver callback.

See the following article for background on ERC-721.

[ERC721] An introduction to ERC-721

  • ERC-721 safe transfer checks that a destination contract acknowledges the NFT through its receiver interface.

This check reduces the risk of locking an NFT inside a contract that cannot handle it.

Why the standard specifies creation bytes

ERC-7613 defines the Puppet as a byte sequence for deployment.

  • Creation code runs during deployment and returns the runtime bytecode that is stored on-chain.
  • A blob of bytes is simply a sequence of bytes.

Standardizing the bytes helps implementations in different languages and frameworks deploy the same Puppet without depending on a particular compiler. Helper tools and libraries can support deployment outside the scope of the standard. The same creation bytes also keep the creation-code hash constant for CREATE2 address calculation.

An alternative to CREATE3

A Puppet can be deployed at a predictable address while keeping its delegated logic flexible. In some designs this makes it an alternative to the CREATE3 pattern.

  • CREATE3 is a deployment pattern, not an EVM opcode. It is often used to make the final address independent of the final contract's creation code for a fixed factory and salt.

A factory can deploy the Puppet deterministically with CREATE2 and then have it deploy the final contract with ordinary CREATE. This can replace a CREATE3 factory.

Low deployment cost and deterministic addresses

The proposal reports the following figures.

  • Runtime bytecode is 66 bytes.
  • Creation code is 62 bytes.
  • Deployment costs about 45K gas.
  • This is about 4K gas more than a minimal clone proxy.

A clone proxy uses a small amount of bytecode to forward execution to an implementation, as in EIP-1167.

See the following article for background on EIP-1167.

Like a clone, a Puppet has creation code small enough to assemble in Solidity's memory scratch space. Since the bytes are specified directly, compiler versions and optimization settings do not change the creation-code hash used to predict a CREATE2 address.

Specification

Input format for delegated calls

The Puppet reads its target from the input data.

Position Contents
First 32 bytes ABI-encoded address of the delegatecall target
Bytes after the first 32 Input data for the delegated call

ABI encoding pads the 20-byte address on the left with zeros to produce a 32-byte word. The Puppet uses the first word to identify the target and forwards the remainder unmodified.

text
calldata =
| 0..31 bytes                     | 32..end bytes          |
| delegatecall 先アドレス(ABI形式) | 実行したい関数の calldata |

Conditions that disable delegation

The Puppet does not delegate if any of the following conditions holds.

  1. The caller (CALLER) is not the deployer.
  2. The input is shorter than 32 bytes.
  3. The first 32 bytes do not hold an ABI-encoded address.

Delegation decision flow

The original diagrams retain their Japanese labels.

flowchart TD
    A[コントラクトが呼ばれる] --> B{CALLER == deployer ?}
    B -- No --> X[何も実行せず終了]
    B -- Yes --> C{calldata長 >= 32 ?}
    C -- No --> X
    C -- Yes --> D{先頭32BがABI形式address ?}
    D -- No --> X
    D -- Yes --> E[delegatecall を実行]
    E --> F{成功 ?}
    F -- Yes --> G[RETURN(戻りデータを返す)]
    F -- No --> H[REVERT(戻りデータを返す)]

Why a plain ETH transfer does not delegate

A plain ETH transfer supplies no call data. Its input length is zero, so the second guard applies. The Puppet accepts the ETH and exits without a delegatecall. Calls that intentionally include input follow the normal guard rules.

Deploying a Puppet with creation code

text
0x604260126D60203D3D3683113D3560A01C17733D3360147F331817604057823603803D943D373D3D355AF43D82803E903D91604057FD5BF36034525252F3

The creation code assembles the runtime code and returns it with RETURN.

How the creation code builds the runtime

graph LR
    A[code 1] --> B[deployer address]
    B --> C[code 2]
  • The first and last code segments are fixed byte sequences.
  • The creation code reads the deployer's address from CALLER.
  • It places that address between the two segments.

The runtime code embeds the deployer address, so it does not need to read storage to check the caller.

Runtime behavior

  1. Check calldata and CALLER to decide whether to delegate.
  2. If the checks fail, exit without delegating.
  3. If they pass, read the target from the first 32 bytes, copy the remaining payload, and execute DELEGATECALL.
  4. Propagate the return data, returning on success and reverting on failure.

Handling the payload

flowchart LR
    A[calldata全体] --> B[先頭32Bを除外]
    B --> C[payload]
    C --> D[delegatecall の calldata として使用]

The Puppet does not interpret the payload. The target code decides how to use it.

Additional Notes

Design goals: low cost and reuse

ERC-7613 aims to minimize deployment and execution costs and to make the Puppet useful inside other contract designs. The Puppet serves as an execution container with its own address, balance, and storage. Its own routine uses no storage for authorization, has few branches, and makes the delegation path easy to follow.

Why not write it in Solidity?

A regular Solidity contract with inline Yul could implement the same behavior. Compiler-generated dispatch and safety checks would increase bytecode size and could add deployment and execution costs.

Compiler versions and optimization settings can also change the resulting bytecode. CREATE2 addresses depend on the exact creation bytes, so identical source could yield different addresses across builds. Those properties make this potential implementation a poor fit for this standard.

Why not use an EIP-1167 clone?

An alternative is a minimal clone that delegates to an implementation of the Puppet.

flowchart LR
    A[ユーザー呼び出し] --> B[クローンプロキシ]
    B -->|delegatecall| C[Puppet実装コントラクト]
    C -->|delegatecall| D[実際のロジック]

Clones are inexpensive to deploy, and CREATE2 deployments remain predictable if their inputs are known. However, execution introduces a second delegatecall, from clone to Puppet implementation and then from Puppet implementation to target logic. This adds gas and requires deploying and managing the shared implementation.

The clone's creation code contains the implementation address. Changing that address changes the clone's predicted address, so address calculation depends on the implementation and deployment order.

Why not use a beacon proxy?

A beacon proxy queries a beacon contract for its target implementation before delegating. Safely querying the beacon adds code and execution overhead. Keeping deployments small could require combining the beacon with a clone, adding further contracts and deployment steps.

Changing the target through a beacon also requires a state update. A Puppet chooses the target from the call data each time it delegates.

Trade-offs among implementations

Approach Deployment cost Execution cost Architecture CREATE2 compatibility Target flexibility
Solidity implementation High High Moderate Poor High
Clone proxy Medium Somewhat high Complex Constrained Low
Beacon proxy High High Very complex Poor Low
Puppet Low Low Very simple Good Very high

Reference Implementation

Puppet.sol
library Puppet {
    bytes internal constant CREATION_CODE =
        hex"604260126D60203D3D3683113D3560A01C17733D3360147F33181760405782"
        hex"3603803D943D373D3D355AF43D82803E903D91604057FD5BF36034525252F3";
    bytes32 internal constant CREATION_CODE_HASH = keccak256(CREATION_CODE);

    /// @notice Deploy a new puppet.
    /// @return instance The address of the puppet.
    function deploy() internal returns (address instance) {
        bytes memory creationCode = CREATION_CODE;
        assembly {
            instance := create(0, add(creationCode, 32), mload(creationCode))
        }
        require(instance != address(0), "Failed to deploy the puppet");
    }

    /// @notice Deploy a new puppet under a deterministic address.
    /// @param salt The salt to use for the deterministic deployment.
    /// @return instance The address of the puppet.
    function deployDeterministic(bytes32 salt) internal returns (address instance) {
        bytes memory creationCode = CREATION_CODE;
        assembly {
            instance := create2(0, add(creationCode, 32), mload(creationCode), salt)
        }
        require(instance != address(0), "Failed to deploy the puppet");
    }

    /// @notice Calculate the deterministic address for a puppet deployment made by this contract.
    /// @param salt The salt to use for the deterministic deployment.
    /// @return predicted The address of the puppet.
    function predictDeterministicAddress(bytes32 salt) internal view returns (address predicted) {
        return predictDeterministicAddress(salt, address(this));
    }

    /// @notice Calculate the deterministic address for a puppet deployment.
    /// @param salt The salt to use for the deterministic deployment.
    /// @param deployer The address of the deployer of the puppet.
    /// @return predicted The address of the puppet.
    function predictDeterministicAddress(bytes32 salt, address deployer)
        internal
        pure
        returns (address predicted)
    {
        bytes32 hash = keccak256(abi.encodePacked(hex"ff", deployer, salt, CREATION_CODE_HASH));
        return address(uint160(uint256(hash)));
    }

    function delegationCalldata(address delegateTo, bytes memory data)
        internal
        pure
        returns (bytes memory payload)
    {
        return abi.encodePacked(bytes32(uint256(uint160(delegateTo))), data);
    }
}

Security

Bytecode based on a familiar proxy design

ERC-7613 follows the structure of known minimal proxies where practical. Their delegation flow and return or revert behavior are familiar to auditors. Reusing recognizable patterns makes it easier to focus the review on what the Puppet changes.

Why the target address uses ABI encoding

The target occupies an ABI address word. Requiring that format reduces the chance that other data forwarded by the deployer will be interpreted as a delegation target.

Accidental delegation risk

The deployer's identity check alone does not establish intent. Calls that forward caller-provided data must avoid letting unrelated input be interpreted as a delegation instruction.

ABI address validation

To delegate, the input must be at least 32 bytes long, and the first word must represent a correctly padded ABI address. Its upper 12 bytes must be zero, and its lower 20 bytes hold the address. Ordinary calls with nonzero function selectors fail this padding check.

Why the selector 0x00000000 is unusual

A Solidity function selector is the first 4 bytes of the Keccak-256 hash of the function signature. A selector of 0x00000000 does not by itself make the full address word valid. The other padding bytes and caller check still matter. Deployers should only forward or construct inputs they intend the Puppet to interpret as delegation instructions.

flowchart TD
    A[第三者が calldata を用意] --> B[deployer が Puppet を呼ぶ]
    B --> C{ABI形式 address チェック}
    C -- 不正 --> D[delegatecall しない]
    C -- 正常 --> E[deployerの明示的な操作]
    E --> F[意図した delegatecall のみ実行]

Taken together, the checks distinguish the intended, explicitly encoded call format from ordinary calls.

References

Igor Żuk (@CodeSandwich), "ERC-7613: Puppet Proxy Contract [DRAFT]," Ethereum Improvement Proposals, no. 7613, February 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7613.

Conclusion

ERC-7613 defines a minimal proxy whose deployer chooses its execution logic through calldata. The Puppet keeps its own address, storage, and balance while executing the selected code with delegatecall.

If you have questions, feel free to send me a direct message on Twitter.

Twitter @cardene777

I also publish on these sites.