MCPcopy Create free account
hub / github.com/ChainSecurity/deployment_validation / get_eth_codehash

Function get_eth_codehash

lib/web3.rs:1021–1040  ·  view source on GitHub ↗
(
    config: &DVFConfig,
    address: &Address,
    block_num: u64,
)

Source from the content-addressed store, hash-verified

1019}
1020
1021pub fn get_eth_codehash(
1022 config: &DVFConfig,
1023 address: &Address,
1024 block_num: u64,
1025) -> Result<String, ValidationError> {
1026 let code = get_eth_code(config, address, block_num)?;
1027 let code_bytes = hex::decode(code.trim_start_matches("0x"))?;
1028
1029 // Hashing the contract code
1030 let mut hasher = Keccak::v256();
1031 let mut output = [0u8; 32];
1032 hasher.update(&code_bytes);
1033 hasher.finalize(&mut output);
1034
1035 let code_hash = format!("0x{}", hex::encode(output));
1036
1037 info!("The codehash of the contract is {}", code_hash);
1038
1039 Ok(code_hash)
1040}
1041
1042fn u256_to_bytes(u: &U256) -> [u8; 32] {
1043 let mut res = [0u8; 32];

Callers 2

validate_dvfFunction · 0.85
processFunction · 0.85

Calls 1

get_eth_codeFunction · 0.85

Tested by

no test coverage detected