Skip to content

Default EVM state #15

Answered by Yashiru
eNzueth asked this question in Q&A
Oct 17, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hello @eNzueth,

To initialize a custom contract state, you would first create an AccountState object to represent the state of your contract, and then encapsulate that within an EvmState object which you would use to create a new runner using Runner::new function.

Here's how you could do it:

fn main() {
    // Create a custom AccountState
    let mut storage = HashMap::new();

    // Set the value of the contract slot 0x0 (uint256 public contractBalance)
    storage.insert([0u8; 32], [5u8; 32]);

    // Create the AccountState to represent the contract state
    let account_state = AccountState {
        nonce: 0,
        balance: [10u8; 32],  // Initial balance
        storage,
        c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@eNzueth
Comment options

Answer selected by eNzueth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants