examples: add EVMC_CREATE example to example_vm
@@ -110,7 +110,16 @@ static struct evmc_result execute(struct evmc_instance* instance,
// Assembly: `{ mstore(0, number()) return(0, msize()) }`
const char return_block_number[] = "\x43\x60\x00\x52\x59\x60\x00\xf3";
- if (code_size == (sizeof(return_address) - 1) &&
+ if (msg->kind == EVMC_CREATE)
+ {
+ evmc_address create_address = {
+ {1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
+ ret.status_code = EVMC_SUCCESS;
+ ret.create_address = create_address;
+ ret.gas_left = msg->gas / 10;
+ return ret;
+ }
+ else if (code_size == (sizeof(return_address) - 1) &&
strncmp((const char*)code, return_address, code_size) == 0)
{
static const size_t address_size = sizeof(msg->destination);
