evm

Built-in typed evm assembler

Our ethereum module comes with an end to end integrated, fully typed EVM assembler. Using kimlikdao-lib one can interact deeply with the ethereum network:

  • synthesize and execute one-off EVM scripts (init code) on the fly

  • synthesize contracts and deploy them on the fly

  • interact with preexisting or freshly deployed contracts

Just like regular programs are composed of functions, in our assembler, programs are composed of Fragments. Fragments are pieces of code which start with some type prerequisites on the EVM stack and provides detailed guarantees on the effects of it on the stack.

For instance the gas() method has no prerequisites on the stack, emits a single Word without consuming anything from the stack. In our assembler, this is denoted with the type signature

gas(): () → Word|0

Here are signatures of a few other built-ins:

ret(offset, size): (Locn, Size) → |2
sload(key): (Word) → Word|1
sstore(key, value): (Word, Word) → |2
call(gas, address, value, argsOffset, argsSize, retOffset, retSize):
  (Word, Addr, Word, Locn, Size, Locn, Size) → Bool|7

So far Fragments may be looking just like functions. The differences start when we start composing Fragments. For instance call may behave like the following:

call(gas, address, value, 0, 32, retOffset, retSize):
  (Word, Addr, Word, , , Locn, Size) → Bool, Locn|7

Last updated