/ docs / Host_Guide.md
Host_Guide.md
 1  # EVMC Host Implementation Guide {#hostguide}
 2  
 3  > How to bring EVMC support to Your Ethereum Client.
 4  
 5  ## Host interface
 6  
 7  First of all, you have to implement the Host interface. The Host interface
 8  allows VMs to query and modify Ethereum state during the execution.
 9  
10  The implementation can be done in object-oriented manner. 
11  The ::evmc_host_interface lists the methods any Host must implement.
12  
13  Moreover, each of the methods has a pointer to ::evmc_host_context 
14  as a parameter. The context is owned entirely by the Host allowing a Host instance 
15  to behave as an object with data.
16  
17  ## VM usage
18  
19  When Host implementation is ready it's time to start using EVMC VMs.
20  
21  1. Firstly, create a VM instance. You need to know what is the name of the "create"
22     function in particular VM implementation. The EVMC recommends to name the 
23     function by the VM codename, e.g. ::evmc_create_example_vm().
24     Invoking the create function will give you the VM instance (::evmc_vm). 
25     It is recommended to create the VM instance once.
26     
27  2. If you are interested in loading VMs dynamically (i.e. to use DLLs) 
28     check out the [EVMC Loader](@ref loader) library.
29     
30  3. The ::evmc_vm contains information about the VM like 
31     name (::evmc_vm::name) or ABI version (::evmc_vm::abi_version)
32     and methods.
33     
34  4. To execute code in the VM use the "execute()" method (::evmc_vm::execute).
35     You will need:
36     - the code to execute,
37     - the message (::evmc_message) object that describes the execution context,
38     - the Host instance, passed as ::evmc_host_context pointer.
39     
40  5. When execution finishes you will receive ::evmc_result object that describes
41     the results of the execution.
42     
43  Have fun!