alloy-rs / alloy-rs/examples

ERC1167 demonstration

Đang mở
#182 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
234
Fork
64
Merge trung bình
19 giờ 34 phút
Pull request đã merge (30 ngày)
6

Mô tả

### Component

consensus, eips, genesis

### Describe the feature you would like

https://eips.ethereum.org/EIPS/eip-1167
```rust
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(...)`](https://docs.rs/alloy/latest/alloy/primitives/struct.Address.html#method.create2).

### Additional context

_No response_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.