Skip to content

EVM Charge: gas sponsoring for permit2 approve tx #264

@Xeift

Description

@Xeift

Describe the feature

I've spent some time reading the EVM Charge spec. In the Permit2 Payload section, it is mentioned:

## Permit2 Payload (type="permit2") {#permit2-payload}
The RECOMMENDED credential type. The client signs an off-chain
EIP-712 Permit2 authorization message. The server constructs
and submits the on-chain transaction, paying gas from its own
balance. The client never interacts with the chain directly.
This type requires that the Permit2 contract is deployed on
the target chain and that the client has an active ERC-20
approval to the Permit2 contract (a one-time operation per
token per chain).

So to my understanding, the permit2 credential type in evm requires the client to have signed an approval for the Permit2 contract by themselves in advance, and currently does not support gas sponsoring for the approve tx.

This means the client needs to prepare native coin to pay the gas if they use a traditional EOA, which leads to a bad UX.

I acknowledge that Privy already supports EIP-7702 + Paymaster, but based on the doc, I believe it does not support Permit2.

x402 v2 has introduced the erc20ApprovalGasSponsoring extension. When enabled:

  1. The client signs an approve EIP-1559 raw tx, and instead of broadcasting it, sends this signed tx to the server.
  2. The server, or more accurately, the facilitator, simply transfers ETH to the client's EOA.
  3. The server broadcasts the tx from step 1.

Steps 2 and 3 need to be atomic.
On Ethereum, this can be achieved by using an MEV bundle, such as eth_sendBundle in Flashbots.
On Base, there seems to be no public method like eth_sendBundle. Flashblocks + Private RPC might be a solution, but this does not guarantee atomicity.
On MegaETH, Mini-blocks and realtime_sendRawTransaction might be a solution. Similar to Flashblocks, this does not guarantee atomicity.
On Sei, SIP-2 is the exact solution, though it is still in draft. It maintains atomicity.

With erc20ApprovalGasSponsoring, x402 clients do not need to have ETH in their EOA and do not need to approve Permit2 in advance. Their SDK handles this automatically. But yes, this increases the complexity of the server/facilitator-side implementation, especially the atomic part. Different chains have different block producers.

x402 uses EIP-3009 (authorization) as the main method to settle txs, so agents do not need to have native coin in their EOA; only USDC is required, which is really convenient.

IMO, if EVM Charge mainly uses permit2, then gas sponsoring for the approve tx will be the main problem we need to solve in the future. It's inconvenient that agent need to have native gas coin in their address. Solve this can improve adoption too.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions