Skip to content

Commit

Permalink
ERC7744 refactor (#42)
Browse files Browse the repository at this point in the history
* ERC7744 refactor

* added case for self-destruct in erc7744, address change accordingly

* upd deploy script

* readme

* bump ts ver

* prettier ignore abi dir

* Update orange-mayflies-suffer.md

* Update orange-mayflies-suffer.md
  • Loading branch information
peersky authored Jan 18, 2025
1 parent 3305b82 commit 8a86a52
Show file tree
Hide file tree
Showing 19 changed files with 220 additions and 211 deletions.
15 changes: 15 additions & 0 deletions .changeset/orange-mayflies-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@peeramid-labs/eds": major
---

- Removed metadata from compilation artifact
- Renamed CodeIndex artifacts into ERC7744 to be more explicit
- Adjusted tests
- Bumped compilation for ERC7744 to solidity 0.8.28
- Added artifacts to npm package exports to allow 3rd party projects deploy ERC7744 on their own

## Breaking changes
- ERC7744 Code Index address changes to `0xC0dE1D2F7662c63796E544B2647b2A94EE658E07`
- ICodeIndexRef.sol was removed, you can now directly interface from IERC7744
- ICodeIndex.sol and CodeIndex.sol renamed to IERC7744.sol and ERC7744.sol

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,4 @@ types/typechain
bin/
types

abi/
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# **Ethereum Distribution System**

The Ethereum Distribution System (EDS) is an open and decentralized, fully on-chain distribution (factory) system for Ethereum smart contracts. Using EDS enables developers to publish and reuse each other's code in a trustless manner. Built-in system for [semantic versioning](http://semver.org/), managing versions and combining into higher level distributions allows developers to avoid using upgradability patterns, instead relying on version control.
The Ethereum Distribution System (EDS) is an open and decentralized, fully on-chain distribution (factory) system for Ethereum smart contracts. Using EDS enables developers to publish and reuse each other's code in a trustless manner. Built-in system for [semantic versioning](http://semver.org/), managing versions and combining into higher level distributions allows developers to avoid using upgradability patterns, instead relying on version control.
System provisions for generic interfaces for distributors, developers and installers, each with their own responsibilities and constraints.

## **Use cases**

* **Factory Framework**: Instead of writing own factory, just write a distribution and register it
* **Ship faster**: Reduce the number of needed deployment artifacts to ship your project. Re-using other packages instead\!
* **Security oracles**: Disconnect vulnerable code from your users in O(1)
* **Semantic versioning with EIP712**: Instead of having to figure out "what to write in EIP712 constructor" just use the built in version control system\!
* **User owned upgradability**: Get more user trust by allowing them to decide when to upgrade
* **Improve user UX**: Configure trust within instance or distribution, so that your users do not need to set allowances and issue permits anymore\!
* **On-chain github**: Refer bytecode instead of location using ([ERC7744](https://eips.ethereum.org/EIPS/eip-7744))
* **Factory Framework**: Instead of writing own factory, just write a distribution and register it
* **Ship faster**: Reduce the number of needed deployment artifacts to ship your project. Re-using other packages instead\!
* **Security oracles**: Disconnect vulnerable code from your users in O(1)
* **Semantic versioning with EIP712**: Instead of having to figure out "what to write in EIP712 constructor" just use the built in version control system\!
* **User owned upgradability**: Get more user trust by allowing them to decide when to upgrade
* **Improve user UX**: Configure trust within instance or distribution, so that your users do not need to set allowances and issue permits anymore\!
* **On-chain github**: Refer bytecode instead of location using ([ERC7744](https://eips.ethereum.org/EIPS/eip-7744))
* **Better Monetize your apps and services**: As your application becomes distributed, and wrapped, you may directly build in payment systems and subscription models on-chain\!

## **Overview**

This system acts as a generalized and efficient factory which is designed in one-fits-all principle. It achieves this by splitting EDS users in following groups:

* **Developers**: Create a distributable (stateless) software that can be instantiated. It can use already deployed contracts and functionality\!
* **Distributors**: Security firms and traditional distributor agencies. Ensure that distributions they list are secure (think of this as a runtime checked audit attestation), trusted and act in their user interest\!
* **Developers**: Create a distributable (stateless) software that can be instantiated. It can use already deployed contracts and functionality\!
* **Distributors**: Security firms and traditional distributor agencies. Ensure that distributions they list are secure (think of this as a runtime checked audit attestation), trusted and act in their user interest\!
* **Smart accounts**: Use Distributor software to plug it into your smart account\!

IN the background, there is extensive use of proxies to map instances, that are proxies, to a right functionality. Instances are also treated as middlewares that are hooked to the distributor with use of [ERC7746](https://eips.ethereum.org/EIPS/eip-7746), in such a way that the caller cannot reach the functionality without first checking with the distributor. The distributor in turn, by default, checks if the instance is a valid distribution.
IN the background, there is extensive use of proxies to map instances, that are proxies, to a right functionality. Instances are also treated as middlewares that are hooked to the distributor with use of [ERC7746](https://eips.ethereum.org/EIPS/eip-7746), in such a way that the caller cannot reach the functionality without first checking with the distributor. The distributor in turn, by default, checks if the instance is a valid distribution.
If the developer wants to manage multiple versions of the same resource, they can create a *Repository* contract to add their own index on top of global.

## Project status: Alpha

We are open for discussion, whether this should be managed trough a governing body as a DAO.
We are open for discussion, whether this should be managed trough a governing body as a DAO.

If you want to be up to date, express your opinion or not miss a thing, please
If you want to be up to date, express your opinion or not miss a thing, please
- subscribe to our twitter: https://x.com/peeramid_labs
- join our discord: https://discord.gg/EddGgGUuWC

Expand All @@ -54,8 +54,8 @@ System components are broken down into four domains: Permission-less, Developer,

##### CodeIndex ([ERC-7744](https://eips.ethereum.org/EIPS/eip-7744))

A stateful, permissionless contract allowing anyone to register associations between bytecode and its on-chain location. Any smart contract may be indexed by `CodeIndex` based on its bytecode.
Proposed `CREATE2` implementation with deterministic address : `0xc0D31d398c5ee86C5f8a23FA253ee8a586dA03Ce`
A stateful, permission less contract allowing anyone to register associations between bytecode and its on-chain location. Any smart contract may be indexed by `CodeIndex` based on its bytecode.
Proposed `CREATE2` implementation with deterministic address : `0xC0dE1D2F7662c63796E544B2647b2A94EE658E07`

##### `Distribution`

Expand Down Expand Up @@ -108,12 +108,12 @@ Larger example of usage can be found in [Rankify project repo](https://github.co

## Support || Contribute

If you want to support this project, please click "sponsor" button, or see our gitcoin page:
If you want to support this project, please click "sponsor" button, or see our gitcoin page:
https://explorer.gitcoin.co/#/projects/0xd4427d0ffc2b8f58c4ef28410deed1158a7d5e405d6cd5bedb0487441d2ba452



You can reach out us on Discord: https://discord.gg/EddGgGUuWC
You can reach out us on Discord: https://discord.gg/EddGgGUuWC



Expand Down
14 changes: 10 additions & 4 deletions deploy/01_codeIndex.ts → deploy/ERC7744.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();
const salt = "0x220a70730c743a005cfd55180805d2c0d5b8c7695c5496100dcffa91c02befce";
// generated with cast create2 --starts-with c0de1d
// const bigIntValue = BigInt(
// "50974397650477774973013714513428960054656154370774770732424793889552745009750"
// );
// // Convert to a hexadecimal string
// const salt = "0x" + bigIntValue.toString(16);
const salt = "0x70b27c94ed692bfb60748cee464ef910d4bf768ac1f3a63eeb4c05258f629256";

console.log("salt", salt);
const result = await deploy("CodeIndex", {
const result = await deploy("ERC7744", {
deterministicDeployment: salt,
from: deployer,
skipIfAlreadyDeployed: true
});

console.log("CodeIndex deployed at", result.address);
console.log("ERC7744 deployed at", result.address);
if (result.bytecode) {
const codeHash = ethers.utils.keccak256(result.bytecode);
console.log(`CodeHash: ${codeHash}`);
}
};

export default func;
func.tags = ["code_index"];
func.tags = ["ERC7744"];
5 changes: 4 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ export default {
solidity: {
compilers: [
{
version: "0.8.20",
version: "0.8.28",
settings: {
optimizer: {
enabled: true,
runs: 200000
},
metadata: {
bytecodeHash: "none"
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"src",
"types",
"scripts",
"docs"
"docs",
"artifacts"
],
"description": "Generalized factory implementation for reproducible ethereum smart contract instantiation",
"scripts": {
Expand Down Expand Up @@ -77,6 +78,6 @@
"cli-table": "^0.3.11",
"hardhat-gas-reporter": "^1.0.9",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"typescript": "^5.7.3"
}
}
2 changes: 1 addition & 1 deletion playbook/utils/deploy-to-local-anvil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ sed -i '' 's|// import '\''./playbook'\''|import '\''./playbook'\''|' ./hardhat.

rm -rf ./deployments/localhost
export NODE_ENV=TEST
pnpm hardhat deploy --tags code_index --network localhost
pnpm hardhat deploy --tags ERC7744 --network localhost
Loading

0 comments on commit 8a86a52

Please sign in to comment.