Skip to content

Commit

Permalink
Add tutorial for EIP-7702
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Jan 6, 2025
1 parent 16e5a10 commit d8539d6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pages/advanced/eip-7702/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"overview": "Overview",
"7702-safe": "Safe and EIP-7702"
"7702-safe": "Safe and EIP-7702",
"tutorials": "Tutorials"
}
3 changes: 3 additions & 0 deletions pages/advanced/eip-7702/tutorials/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"approach-1": "Safe proxy as delegation designator"
}
49 changes: 49 additions & 0 deletions pages/advanced/eip-7702/tutorials/approach-1.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Callout } from 'nextra/components'

# Approach 1: Delegate to modified Safe Proxy contract

The tutorial below presents an approach to set delegation designator to a modified Safe Proxy contract discussed in [EIP-7702 approaches](../7702-safe#modified-safe-proxy).

### 1. Setup project

```bash
git clone [email protected]:5afe/safe-eip7702.git
```

### 2. Install dependencies

```bash
cd safe-eip7702/safe-eip7702-contracts
pnpm i
```

### 3. Setup RPC and .env file

- Copy `.env.example` to `.env` and update the values
- Set the relayer and EOA private keys in the `.env` file.
- `RELAYER_PRIVATE_KEY`: Used for paying gas fees
- `ACCOUNT_PRIVATE_KEY`: EOA private key whose code will be set

- Update `hardhat.config.ts` has appropriate values for the network.
- Make sure the contracts are deployed on the network using
```bash
npx hardhat deploy --network <network>
```

### 4. Run the script to set the code

```bash
npx hardhat run src/scripts/1_set_code.ts --network <network>
```

### 5. Execute transaction

- The script `2_execute.ts` can be used to execute a transaction using the EOA which is sponsored by the relayer account. The script will send 1 wei to the relayer account from EOA address.
```bash
npx hardhat run src/scripts/2_execute.ts --network <network>
```

- The script `3_batch_execute.ts` can be used to execute batch transaction using the EOA which is sponsored by the relayer account. The script will execute 2 calls which send 1 wei in each call to the relayer account from EOA address.
```bash
npx hardhat run src/scripts/3_batch_execute.ts --network <network>
```

0 comments on commit d8539d6

Please sign in to comment.