EIP-7702 Integration
EIP-7702 allows an Externally Owned Account (EOA) to temporarily "become" a smart contract. CommissionRoad leverages this to allow users to authorize the CommissionRoadExecutor to act on their behalf.
WHEN TO USE
Use this for Gas Sponsoring or Identity Preservation.
- Example: "A Relayer pays gas for the user's transaction."
- Example: "User wants to mint + stake without two approval signatures."
- Example: "Target protocol checks
msg.senderand requires it to be the User."
Why EIP-7702?
- No Approvals: Since the user is the executor, the contract can move the user's tokens without a prior
approve()transaction. - Atomic: You can perform Mint, Approve, Swap, and Pay Commission in one single atomic transaction.
- Identity: The transactions originate from the User's address, not the CommissionRoad contract.
Implementation
1. Sign Authorization
The user signs a message authorizing the CommissionRoadExecutor code to run in their account context.
import { verifyAuthorization } from "viem/experimental";
const authorization = await walletClient.signAuthorization({
contractAddress: commissionRoadExecutorAddress,
chainId: 1,
nonce: 0,
});2. Broadcast Transaction
The transaction can be sent by anyone (the user or a relayer). The payload is a self-call to the user's address, executing the batchCall function of the adopted code.
// Encode the 'batchCall' function of the Executor
const data = encodeFunctionData({
abi: executorAbi,
functionName: "batchCall",
args: [batchData, nftId] // nftId required for allowlist enforcement
});
// Send transaction
await walletClient.sendTransaction({
to: userAddress, // Self-call!
data: data,
authorizationList: [authorization] // EIP-7702 Magic
});Allowlist Enforcement
The CommissionRoadExecutor reads allowlist state directly from the CommissionRoad contract. If the NFT owner has enabled a allowlist, the Executor checks every call target before execution — the same restrictions that apply to commissionCall and commissionPlan apply here.
NOTE
Both execute and batchCall accept an nftId parameter so the correct allowlist is applied. NFT owners only need to manage their allowlist in one place — on the CommissionRoad contract.