mirror of https://github.com/status-im/evmc.git
Merge pull request #64 from ethereum/examples
examples: update capi for latest interface
This commit is contained in:
commit
6dca3222da
|
@ -1,4 +1,5 @@
|
|||
#include <evmc/evmc.h>
|
||||
#include <evmc/helpers.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
@ -165,8 +166,8 @@ static const struct evmc_context_fn_table ctx_fn_table = {
|
|||
/// Example how the API is supposed to be used.
|
||||
int main()
|
||||
{
|
||||
struct evmc_instance* jit = evmc_create_examplevm();
|
||||
if (jit->abi_version != EVMC_ABI_VERSION)
|
||||
struct evmc_instance* vm = evmc_create_examplevm();
|
||||
if (vm->abi_version != EVMC_ABI_VERSION)
|
||||
return 1; // Incompatible ABI version.
|
||||
|
||||
const uint8_t code[] = "Place some EVM bytecode here";
|
||||
|
@ -189,7 +190,7 @@ int main()
|
|||
msg.gas = gas;
|
||||
msg.depth = 0;
|
||||
|
||||
struct evmc_result result = jit->execute(jit, &ctx, EVMC_HOMESTEAD, &msg, code, code_size);
|
||||
struct evmc_result result = vm->execute(vm, &ctx, EVMC_HOMESTEAD, &msg, code, code_size);
|
||||
|
||||
printf("Execution result:\n");
|
||||
if (result.status_code != EVMC_SUCCESS)
|
||||
|
@ -209,9 +210,8 @@ int main()
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
if (result.release)
|
||||
result.release(&result);
|
||||
jit->destroy(jit);
|
||||
evmc_release_result(&result);
|
||||
evmc_destroy(vm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue