Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions contracts/local-deployments-artifacts/deployEIP7702Contracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { ethers } from "ethers";
import {
contractName as eip7702TestNestedName,
abi as eip7702TestNestedAbi,
bytecode as eip7702TestNestedBytecode,
} from "./static-artifacts/eip7702/Eip7702TestNested.json";
import {
contractName as eip77022DelegatedName,
abi as eip77022DelegatedAbi,
bytecode as eip77022DelegatedBytecode,
} from "./static-artifacts/eip7702/Eip77022Delegated.json";
import {
contractName as eip7702TestEntrypointName,
abi as eip7702TestEntrypointAbi,
bytecode as eip7702TestEntrypointBytecode,
} from "./static-artifacts/eip7702/Eip7702TestEntrypoint.json";
import { deployContractFromArtifacts } from "../common/helpers/deployments";

async function main() {
const ORDERED_NONCE_POST_L2MESSAGESERVICE = 3;
const ORDERED_NONCE_POST_TOKENBRIDGE = 5;
const ORDERED_NONCE_POST_L2_TEST_ERC20 = 1;

const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
const wallet = new ethers.Wallet(process.env.DEPLOYER_PRIVATE_KEY!, provider);

let baseNonce: number;
if (!process.env.L2_NONCE) {
baseNonce = await wallet.getNonce();
} else {
baseNonce =
parseInt(process.env.L2_NONCE) +
ORDERED_NONCE_POST_L2MESSAGESERVICE +
ORDERED_NONCE_POST_TOKENBRIDGE +
ORDERED_NONCE_POST_L2_TEST_ERC20;
}

const fees = {
maxFeePerGas: 7_200_000_000_000n,
maxPriorityFeePerGas: 7_000_000_000_000n,
};

await deployEIP7702TestNested(wallet, baseNonce, fees);
await deployEIP77022Delegated(wallet, baseNonce + 1, fees);
await deployEIP7702TestEntrypoint(wallet, baseNonce + 2, fees);
}

async function deployEIP7702TestNested(
wallet: ethers.Wallet,
nonce: number,
fees: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint },
): Promise<string> {
const nestedContract = await deployContractFromArtifacts(
eip7702TestNestedName,
eip7702TestNestedAbi,
eip7702TestNestedBytecode,
wallet,
{
nonce,
...fees,
},
);

return nestedContract.getAddress();
}

async function deployEIP77022Delegated(
wallet: ethers.Wallet,
nonce: number,
fees: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint },
): Promise<string> {
const delegatedContract = await deployContractFromArtifacts(
eip77022DelegatedName,
eip77022DelegatedAbi,
eip77022DelegatedBytecode,
wallet,
{
nonce,
...fees,
},
);

return delegatedContract.getAddress();
}

async function deployEIP7702TestEntrypoint(
wallet: ethers.Wallet,
nonce: number,
fees: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint },
): Promise<string> {
const entrypointContract = await deployContractFromArtifacts(
eip7702TestEntrypointName,
eip7702TestEntrypointAbi,
eip7702TestEntrypointBytecode,
wallet,
{
nonce,
...fees,
},
);

return entrypointContract.getAddress();
}

main().catch((error) => {
console.error(error);
process.exit(1);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Eip77022Delegated",
"sourceName": "src/_testing/integration/eip-7702/Eip77022Delegated.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "ValueSet",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "getValue",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_newValue",
"type": "uint256"
},
{
"internalType": "address",
"name": "_nestedContract",
"type": "address"
}
],
"name": "setValue",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "storedValue",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x6080604052348015600e575f5ffd5b506102328061001c5f395ff3fe608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80633472df22146100435780633ccc0522146100585780638d48538d1461009f575b5f5ffd5b6100566100513660046101b2565b6100be565b005b61008d6100663660046101dc565b73ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205490565b60405190815260200160405180910390f35b61008d6100ad3660046101dc565b5f6020819052908152604090205481565b335f818152602081815260409182902085905590518481527ff3f57717dff9f5f10af315efdbfadc60c42152c11fc0c3c413bbfbdc661f143c910160405180910390a26040517f552410770000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff82169063552410779066038d7ea4c68000906024015f604051808303818588803b15801561016f575f5ffd5b505af1158015610181573d5f5f3e3d5ffd5b50505050505050565b803573ffffffffffffffffffffffffffffffffffffffff811681146101ad575f5ffd5b919050565b5f5f604083850312156101c3575f5ffd5b823591506101d36020840161018a565b90509250929050565b5f602082840312156101ec575f5ffd5b6101f58261018a565b939250505056fea2646970667358221220e9f7c8c75de1fe214a74f605de7f15ab9590c4c2d3a014808ed0f0e2e785e73464736f6c63430008210033",
"deployedBytecode": "0x608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80633472df22146100435780633ccc0522146100585780638d48538d1461009f575b5f5ffd5b6100566100513660046101b2565b6100be565b005b61008d6100663660046101dc565b73ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205490565b60405190815260200160405180910390f35b61008d6100ad3660046101dc565b5f6020819052908152604090205481565b335f818152602081815260409182902085905590518481527ff3f57717dff9f5f10af315efdbfadc60c42152c11fc0c3c413bbfbdc661f143c910160405180910390a26040517f552410770000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff82169063552410779066038d7ea4c68000906024015f604051808303818588803b15801561016f575f5ffd5b505af1158015610181573d5f5f3e3d5ffd5b50505050505050565b803573ffffffffffffffffffffffffffffffffffffffff811681146101ad575f5ffd5b919050565b5f5f604083850312156101c3575f5ffd5b823591506101d36020840161018a565b90509250929050565b5f602082840312156101ec575f5ffd5b6101f58261018a565b939250505056fea2646970667358221220e9f7c8c75de1fe214a74f605de7f15ab9590c4c2d3a014808ed0f0e2e785e73464736f6c63430008210033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Eip7702TestEntrypoint",
"sourceName": "src/_testing/integration/eip-7702/Eip7702TestEntrypoint.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "ValueSet",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_newValue",
"type": "uint256"
},
{
"internalType": "address",
"name": "_delegatingAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_nestedContract",
"type": "address"
}
],
"name": "setValue",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x6080604052348015600e575f5ffd5b506101968061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80636c63b80a1461002d575b5f5ffd5b61004061003b366004610127565b610042565b005b6040517f3472df220000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff8281166024830152831690633472df22906044015f604051808303815f87803b1580156100af575f5ffd5b505af11580156100c1573d5f5f3e3d5ffd5b50506040518581523392507ff3f57717dff9f5f10af315efdbfadc60c42152c11fc0c3c413bbfbdc661f143c915060200160405180910390a2505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610122575f5ffd5b919050565b5f5f5f60608486031215610139575f5ffd5b83359250610149602085016100ff565b9150610157604085016100ff565b9050925092509256fea26469706673582212200697a99ad30f76f214e493a4ab2e86bcaa2afd849a0db32464e705f3752fc5b364736f6c63430008210033",
"deployedBytecode": "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80636c63b80a1461002d575b5f5ffd5b61004061003b366004610127565b610042565b005b6040517f3472df220000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff8281166024830152831690633472df22906044015f604051808303815f87803b1580156100af575f5ffd5b505af11580156100c1573d5f5f3e3d5ffd5b50506040518581523392507ff3f57717dff9f5f10af315efdbfadc60c42152c11fc0c3c413bbfbdc661f143c915060200160405180910390a2505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610122575f5ffd5b919050565b5f5f5f60608486031215610139575f5ffd5b83359250610149602085016100ff565b9150610157604085016100ff565b9050925092509256fea26469706673582212200697a99ad30f76f214e493a4ab2e86bcaa2afd849a0db32464e705f3752fc5b364736f6c63430008210033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Eip7702TestNested",
"sourceName": "src/_testing/integration/eip-7702/Eip7702TestNested.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "ValueSet",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "getValue",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "newValue",
"type": "uint256"
}
],
"name": "setValue",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "storedValue",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x6080604052348015600e575f5ffd5b506101978061001c5f395ff3fe608060405260043610610033575f3560e01c80633ccc052214610037578063552410771461008a5780638d48538d1461009f575b5f5ffd5b348015610042575f5ffd5b50610078610051366004610110565b73ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205490565b60405190815260200160405180910390f35b61009d61009836600461014a565b6100ca565b005b3480156100aa575f5ffd5b506100786100b9366004610110565b5f6020819052908152604090205481565b335f818152602081815260409182902084905590518381527ff3f57717dff9f5f10af315efdbfadc60c42152c11fc0c3c413bbfbdc661f143c910160405180910390a250565b5f60208284031215610120575f5ffd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610143575f5ffd5b9392505050565b5f6020828403121561015a575f5ffd5b503591905056fea264697066735822122011d94bd2ef2c681b2e9924e2d8d449ade40710b32d2708cd2f7bd39aab1ff9be64736f6c63430008210033",
"deployedBytecode": "0x608060405260043610610033575f3560e01c80633ccc052214610037578063552410771461008a5780638d48538d1461009f575b5f5ffd5b348015610042575f5ffd5b50610078610051366004610110565b73ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205490565b60405190815260200160405180910390f35b61009d61009836600461014a565b6100ca565b005b3480156100aa575f5ffd5b506100786100b9366004610110565b5f6020819052908152604090205481565b335f818152602081815260409182902084905590518381527ff3f57717dff9f5f10af315efdbfadc60c42152c11fc0c3c413bbfbdc661f143c910160405180910390a250565b5f60208284031215610120575f5ffd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610143575f5ffd5b9392505050565b5f6020828403121561015a575f5ffd5b503591905056fea264697066735822122011d94bd2ef2c681b2e9924e2d8d449ade40710b32d2708cd2f7bd39aab1ff9be64736f6c63430008210033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.33;

import { Eip7702TestNested } from "./Eip7702TestNested.sol";

/// @title Eip77022Delegated
/// @notice Test contract for EIP-7702 (Set Code) functionality with nested contract calls.
/// @author Consensys Software Inc.
/// @custom:security-contact security-report@linea.build
contract Eip77022Delegated {
/// @notice Mapping storing a value for each address.
mapping(address => uint256) public storedValue;

/// @notice Emitted when a value is set for an address.
/// @param sender The address that initiated the value change.
/// @param value The new value set.
event ValueSet(address indexed sender, uint256 value);

/// @notice Sets a value for the caller and delegates a nested call to another contract.
/// @param _newValue The value to store for the caller.
/// @param _nestedContract The address of the nested contract to delegate to.
function setValue(uint256 _newValue, address _nestedContract) external {
storedValue[msg.sender] = _newValue;
emit ValueSet(msg.sender, _newValue);
Eip7702TestNested(_nestedContract).setValue{ value: 1000000000000000 }(_newValue);
}

/// @notice Retrieves the stored value for a given user.
/// @param user The address to query.
/// @return The stored value for the user.
function getValue(address user) external view returns (uint256) {
return storedValue[user];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.33;

import { Eip77022Delegated } from "./Eip77022Delegated.sol";

/// @title Eip7702TestEntrypoint
/// @notice Outer test contract that orchestrates calls through nested and delegated addresses via EIP-7702.
/// @author Consensys Software Inc.
/// @custom:security-contact security-report@linea.build
contract Eip7702TestEntrypoint {
/// @notice Emitted when a value is set through delegation.
/// @param sender The original sender triggering the delegation.
/// @param value The value set.
event ValueSet(address indexed sender, uint256 value);

/// @notice Delegates a setValue call through an EIP-7702 delegated address to a nested contract.
/// @param _newValue The value to store.
/// @param _delegatingAddress The EOA address that has delegated code.
/// @param _nestedContract The address of the nested contract to call.
function setValue(uint256 _newValue, address _delegatingAddress, address _nestedContract) external {
// Calls the EOA with delegated code to set the value in the nested contract.
Eip77022Delegated(_delegatingAddress).setValue(_newValue, _nestedContract);
emit ValueSet(msg.sender, _newValue);
}
}
Loading
Loading