-
Notifications
You must be signed in to change notification settings - Fork 489
Getting Started EVM
Luke Biery edited this page Jun 21, 2019
·
3 revisions
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.
owner_account = m.create_account(balance=1000)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"), ...)m.transaction(
caller=user_account, address=contract_account, value=uservalue, data=userdata
)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
)EVM does not have a hook like native, instead, the preferred way to perform operations on a running contract is through plugins.
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