Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERC1167 demonstration #182

Open
StackOverflowExcept1on opened this issue Nov 16, 2024 · 2 comments
Open

ERC1167 demonstration #182

StackOverflowExcept1on opened this issue Nov 16, 2024 · 2 comments

Comments

@StackOverflowExcept1on
Copy link

Component

consensus, eips, genesis

Describe the feature you would like

https://eips.ethereum.org/EIPS/eip-1167

use alloy::primitives::{hex, Address, FixedBytes};

const INITIALIZATION_CODE: FixedBytes<10> = FixedBytes::new(hex!("3d602d80600a3d3981f3"));
const RUNTIME_CODE_1: FixedBytes<10> = FixedBytes::new(hex!("363d3d373d3d3d363d73"));
const RUNTIME_CODE_2: FixedBytes<15> = FixedBytes::new(hex!("5af43d82803e903d91602b57fd5bf3"));

pub const fn minimal_proxy_bytecode(address: [u8; 20]) -> [u8; 55] {
    let address = Address::new(address);
    let part1: FixedBytes<20> = INITIALIZATION_CODE.concat_const(RUNTIME_CODE_1);
    let part2: FixedBytes<40> = part1.concat_const(address.0);
    let part3: FixedBytes<55> = part2.concat_const(RUNTIME_CODE_2);
    part3.0
}

We could also make an extension method (a trait in alloy-eips implemented for alloy::primitives::Address) similar to alloy::primitives::Address::create2(...).

Additional context

No response

@StackOverflowExcept1on StackOverflowExcept1on added the enhancement New feature or request label Nov 16, 2024
@nadtech-hub
Copy link

@yash-atreya
Copy link
Member

yash-atreya commented Feb 20, 2025

This is an ERC i.e a standard, can we perhaps have an example of the usage in the https://github.com/alloy-rs/examples/ repo?

The alloy-eips is a crate for types and functionality that goes into a client.

@yash-atreya yash-atreya transferred this issue from alloy-rs/alloy Feb 20, 2025
@yash-atreya yash-atreya changed the title [Feature] Provide EIP1167 API in alloy-eips crate ERC1167 demonstration Feb 20, 2025
@yash-atreya yash-atreya removed the enhancement New feature or request label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants