Skip to content

Commit

Permalink
docs: fix errors in Usage code example (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
charmful0x authored Apr 30, 2024
1 parent cdea2b7 commit 4874471
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,34 @@ The EVM Rust Emulator is a simple in-memory Ethereum Virtual Machine (EVM) emula

## Usage
```rust
use evm_rs_emulator::Runner;

fn main() {
let caller = [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc4, 0x11, 0xe8,
];
let origin: Option<[u8; 20]> = None;
let address: Option<[u8; 20]> = None
let value: Option<[u8; 32]> = None;
let data: Option<Vec<u8>> = None;
let bytecode: Vec<u8> = vec![0x60, 0xff, 0x60, 0xff];
// Create a new interpreter
let mut runner =
Runner::new(caller, origin, address, value, data, None);

// Run all the bytecode
let _ = interpreter.interpret(bytecode, Some(255), true);

// Or run the bytecode OPCODE by OPCODE
runner.bytecode = bytecode;
runner.debug_level = Some(255);
// Run the first 3 opcodes
let _ = runner.interpret_op_code(runner.bytecode[runner.pc]);
let _ = runner.interpret_op_code(runner.bytecode[runner.pc]);
let _ = runner.interpret_op_code(runner.bytecode[runner.pc]);
}
use evm_rs_emulator::Runner;

fn main() {
let caller = [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc4, 0x11, 0xe8,
];
let origin: Option<[u8; 20]> = None;
let address: Option<[u8; 20]> = None;
let value: Option<[u8; 32]> = None;
let data: Option<Vec<u8>> = None;
let bytecode: Vec<u8> = vec![0x60, 0xff, 0x60, 0xff];

// Create a new interpreter
let mut runner =
Runner::new(caller, origin, address, value, data, None);

// Run all the bytecode
let _ = runner.interpret(bytecode.clone(), Some(255), true);

// Or run the bytecode OPCODE by OPCODE
runner.bytecode = bytecode;
runner.debug_level = Some(255);
// Run the first 3 opcodes
let _ = runner.interpret_op_code(runner.bytecode[runner.pc]);
let _ = runner.interpret_op_code(runner.bytecode[runner.pc]);
let _ = runner.interpret_op_code(runner.bytecode[runner.pc]);
}
```
</details>

Expand Down

0 comments on commit 4874471

Please sign in to comment.