revm_interpreter/interpreter_action/
create_inputs.rs

1use context_interface::CreateScheme;
2use primitives::{Address, Bytes, U256};
3
4/// Inputs for a create call
5#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct CreateInputs {
8    /// Caller address of the EVM
9    pub caller: Address,
10    /// The create scheme
11    pub scheme: CreateScheme,
12    /// The value to transfer
13    pub value: U256,
14    /// The init code of the contract
15    pub init_code: Bytes,
16    /// The gas limit of the call
17    pub gas_limit: u64,
18}
19
20impl CreateInputs {
21    /// Returns the address that this create call will create.
22    pub fn created_address(&self, nonce: u64) -> Address {
23        match self.scheme {
24            CreateScheme::Create => self.caller.create(nonce),
25            CreateScheme::Create2 { salt } => self
26                .caller
27                .create2_from_code(salt.to_be_bytes(), &self.init_code),
28        }
29    }
30}