Skip to content

Getting Started EVM

Luke Biery edited this page Jun 21, 2019 · 3 revisions

The basics

To initialize manticore for EVM you can do the following:

from manticore.ethereum import ManticoreEVM

m = MaticoreEVM()

There is no need to run m.run() every call to a contract will initiate a run.

Adding accounts

create_account

owner_account = m.create_account(balance=1000)

Creating the contract

There are 3 ways to pass a contract to manticore

# If you only have byte code
contract_account = m.create_contract(owner=owner_account, init=bytecode)

# If you have contract json with metadata
contract_account = m.json_create_contract(json, owner=owner_account, name="example_contract")

# If you have solitidy source
contract_account = m.solitidy_create_contract(source_code, owner=owner_account)

Once you have the contract setup to your liking you can perform functions on the contract by calling the function

contract_account.function(...)

# You can also pass symbolic values to functions with
contract_account.function(m.make_symbolic_value(name="Name"), ...)

Performing a transaction

transaction

m.transaction(
    caller=user_account, address=contract_account, value=uservalue, data=userdata
)

Symbolic values

You can create symbolic values and pass them as parameters to most functions

symbolic_data = m.make_symbolic_buffer(320)
symbolic_value = m.make_symbolic_value(name="value")

m.transaction(
    caller=user_account, address=contract_account, value=symbolic_value, data=symbolic_data
)

Operating on a running contract

EVM does not have a hook like native, instead, the preferred way to perform operations on a running contract is through plugins.

EVM State

You can access the world in a plugin callback with:

from manticore.core.plugin import Plugin

class testplugin(Plugin)
	def will_decode_instruction_callback(self, state, pc):
		world = state.platform

world

state

Clone this wiki locally