Skip to content

Commit fa24446

Browse files
yann300Aniket-Engg
authored andcommitted
add fully fledge eip7702 template
1 parent 12f7429 commit fa24446

File tree

11 files changed

+187
-2
lines changed

11 files changed

+187
-2
lines changed

apps/remix-ide/src/app/plugins/templates-selection/templates.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export const templates = (intl, plugin) => {
66
{ value: "remixDefault", tagList: ["Solidity"], displayName: intl.formatMessage({ id: 'filePanel.basic' }), description: 'The default project' },
77
{ value: "blank", displayName: intl.formatMessage({ id: 'filePanel.blank' }), IsArtefact: true, description: 'A blank project' },
88
{ value: "simpleEip7702", displayName: 'Simple EIP 7702', IsArtefact: true, description: 'Pectra upgrade allowing externally owned accounts (EOAs) to run contract code.' },
9-
{ value: "accountAbstraction", displayName: 'Account Abstraction', IsArtefact: true, description: 'Experiment with Account Abstraction contracts: (ERC-4337, EIP-7702)' }
9+
{ value: "accountAbstraction", displayName: 'Account Abstraction', IsArtefact: true, description: 'Github repo for ERC-4337 and EIP-7702.' },
10+
{ value: "fullyFledgeEIP7702", displayName: 'Fully Fledge EIP7702 example', IsArtefact: true, description: 'A fully fledge template using EIP7702.' }
1011
]
1112
},
1213
{

libs/remix-ui/workspace/src/lib/utils/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export const TEMPLATE_NAMES = {
1818
'breakthroughLabsUniswapv4Hooks': 'Breakthrough-Labs Uniswapv4Hooks',
1919
'uniswapV4Template': 'Uniswap v4 Template',
2020
'uniswapV4HookBookMultiSigSwapHook': 'Uniswap V4 HookBook MultiSigSwapHook',
21-
'accountAbstraction': 'Account Abstraction Template'
21+
'accountAbstraction': 'Account Abstraction Template',
22+
'fullyFledgeEIP7702': 'EIP7702 Fully Fledge Template',
2223
}
2324

2425
export const TEMPLATE_METADATA: Record<string, TemplateType> = {

libs/remix-ws-templates/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { default as remixDefault } from './templates/remixDefault'
22
export { default as simpleEip7702 } from './templates/simpleEip7702'
3+
export { default as fullyFledgeEIP7702 } from './templates/fullyFledgeEIP7702'
34
export { default as blank } from './templates/blank'
45
export { default as ozerc20 } from './templates/ozerc20'
56
export { default as ozerc721 } from './templates/ozerc721'
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": "*.sol",
5+
"options": {
6+
"printWidth": 80,
7+
"tabWidth": 4,
8+
"useTabs": false,
9+
"singleQuote": false,
10+
"bracketSpacing": false
11+
}
12+
},
13+
{
14+
"files": "*.yml",
15+
"options": {}
16+
},
17+
{
18+
"files": "*.yaml",
19+
"options": {}
20+
},
21+
{
22+
"files": "*.toml",
23+
"options": {}
24+
},
25+
{
26+
"files": "*.json",
27+
"options": {}
28+
},
29+
{
30+
"files": "*.js",
31+
"options": {}
32+
},
33+
{
34+
"files": "*.ts",
35+
"options": {}
36+
}
37+
]
38+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# EIP 7702
2+
3+
This Workspace Template present one of the updates shipped with the Pectra upgrade which occurred in May 2025.
4+
5+
### Basics
6+
7+
In the Ethereum blockchain there are two different types of accounts:
8+
- Externally Owned Account (EOA): which require a private key and could initiate transactions.
9+
- Smart Contract Account: which represents code deployed in the blockchain.
10+
11+
These two concepts are separated: e.g until now EOAs doesn't have code associated to them.
12+
But with the Pectra upgrade, EOA can now host code and can directly run code.
13+
14+
For more information please see [this page](https://eip7702.io)
15+
16+
### How to
17+
18+
This section explains how to run this project. We are going to assign a piece of code to an EOA:
19+
20+
- Verify solidity version 0.8.28 is selected.
21+
- Compile MyToken.sol, Example7702.sol, Spender.sol.
22+
- Deploy Example7702.sol.
23+
- Use delegation on the contract above.
24+
- Run the script `run-eip7702.ts`.
25+
- Copy the logged input data.
26+
- Find the `executeBatch`, copy the data and run the transaction.
27+
- Check that balance of the first and second account has been updated.
28+
29+
30+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "https://github.com/eth-infinitism/account-abstraction/blob/releases/v0.8/contracts/accounts/Simple7702Account.sol";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5+
import "@openzeppelin/contracts/access/Ownable.sol";
6+
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
7+
8+
contract MyToken is ERC20, Ownable, ERC20Permit {
9+
constructor(address initialOwner)
10+
ERC20("MyToken", "MTK")
11+
Ownable(initialOwner)
12+
ERC20Permit("MyToken")
13+
{}
14+
15+
function mint(address to, uint256 amount) public onlyOwner {
16+
_mint(to, amount);
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
2+
3+
contract Spender {
4+
IERC20 public erc20;
5+
constructor(IERC20 _erc20) {
6+
erc20 = _erc20;
7+
}
8+
function send (address from, address to, uint _amount) public {
9+
erc20.transferFrom(from, to, _amount);
10+
}
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
export default async (opts) => {
3+
4+
const filesObj = {
5+
// @ts-ignore
6+
'contracts/Example7702.sol': (await import('!!raw-loader!./contracts/Example7702.sol')).default,
7+
// @ts-ignore
8+
'contracts/MyToken.sol': (await import('!!raw-loader!./contracts/MyToken.sol')).default,
9+
// @ts-ignore
10+
'contracts/Spender.sol': (await import('!!raw-loader!./contracts/Spender.sol')).default,
11+
// @ts-ignore
12+
'scripts/deploy.ts': (await import('!!raw-loader!./scripts/deploy.ts')).default,
13+
// @ts-ignore
14+
'scripts/run-eip7702.ts': (await import('!!raw-loader!./scripts/run-eip7702.ts')).default,
15+
// @ts-ignore
16+
'README.md': (await import('raw-loader!./README.md')).default
17+
}
18+
return filesObj
19+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { ethers } from 'ethers'
2+
3+
/**
4+
* Deploy the given contract
5+
* @param {string} contractName name of the contract to deploy
6+
* @param {Array<any>} args list of constructor' parameters
7+
* @param {Number} accountIndex account index from the exposed account
8+
* @return {Contract} deployed contract
9+
*/
10+
export const deploy = async (contractName: string, args: Array<any>, accountIndex?: number): Promise<ethers.Contract> => {
11+
12+
console.log(`deploying ${contractName}`)
13+
// Note that the script needs the ABI which is generated from the compilation artifact.
14+
// Make sure contract is compiled and artifacts are generated
15+
const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path
16+
17+
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
18+
// 'web3Provider' is a remix global variable object
19+
20+
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex)
21+
22+
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
23+
24+
const contract = await factory.deploy(...args)
25+
26+
// The contract is NOT deployed yet; we must wait until it is mined
27+
await contract.deployed()
28+
return contract
29+
}

0 commit comments

Comments
 (0)