EVMC
evmc::Result Class Reference

The EVM code execution result. More...

#include <evmc.hpp>

Inheritance diagram for evmc::Result:
evmc_result

Public Member Functions

 Result (evmc_status_code _status_code, int64_t _gas_left, int64_t _gas_refund, const uint8_t *_output_data, size_t _output_size) noexcept
 Creates the result from the provided arguments.
 
 Result (evmc_status_code _status_code=EVMC_INTERNAL_ERROR, int64_t _gas_left=0, int64_t _gas_refund=0) noexcept
 Creates the result without output.
 
 Result (evmc_status_code _status_code, int64_t _gas_left, int64_t _gas_refund, const evmc_address &_create_address) noexcept
 Creates the result of contract creation.
 
 Result (const evmc_result &res) noexcept
 Converting constructor from raw evmc_result.
 
 ~Result () noexcept
 Destructor responsible for automatically releasing attached resources.
 
 Result (Result &&other) noexcept
 Move constructor.
 
Resultoperator= (Result &&other) noexcept
 Move assignment operator.
 
evmc_resultraw () noexcept
 Access the result object as a referenced to evmc_result.
 
const evmc_resultraw () const noexcept
 Access the result object as a const referenced to evmc_result.
 
evmc_result release_raw () noexcept
 Releases the ownership and returns the raw copy of evmc_result.
 

Public Attributes

evmc_address create_address
 The address of the possibly created contract.
 
int64_t gas_left
 The amount of gas left after the execution.
 
int64_t gas_refund
 The refunded gas accumulated from this execution and its sub-calls.
 
const uint8_t * output_data
 The reference to output data.
 
size_t output_size
 The size of the output data.
 
enum evmc_status_code status_code
 The execution status code.
 

Detailed Description

The EVM code execution result.

This is a RAII wrapper for evmc_result and objects of this type automatically release attached resources.

Definition at line 331 of file evmc.hpp.

Constructor & Destructor Documentation

◆ Result() [1/5]

evmc::Result::Result ( evmc_status_code  _status_code,
int64_t  _gas_left,
int64_t  _gas_refund,
const uint8_t *  _output_data,
size_t  _output_size 
)
inlineexplicitnoexcept

Creates the result from the provided arguments.

The provided output is copied to memory allocated with malloc() and the evmc_result::release function is set to one invoking free().

Parameters
_status_codeThe status code.
_gas_leftThe amount of gas left.
_gas_refundThe amount of refunded gas.
_output_dataThe pointer to the output.
_output_sizeThe output size.

Definition at line 351 of file evmc.hpp.

356 : evmc_result{make_result(_status_code, _gas_left, _gas_refund, _output_data, _output_size)}
357 {}
constexpr auto make_result
Alias for evmc_make_result().
Definition: evmc.hpp:325
The EVM code execution result.
Definition: evmc.h:395

◆ Result() [2/5]

evmc::Result::Result ( evmc_status_code  _status_code = EVMC_INTERNAL_ERROR,
int64_t  _gas_left = 0,
int64_t  _gas_refund = 0 
)
inlineexplicitnoexcept

Creates the result without output.

Parameters
_status_codeThe status code.
_gas_leftThe amount of gas left.
_gas_refundThe amount of refunded gas.

Definition at line 364 of file evmc.hpp.

367 : evmc_result{make_result(_status_code, _gas_left, _gas_refund, nullptr, 0)}
368 {}

◆ Result() [3/5]

evmc::Result::Result ( evmc_status_code  _status_code,
int64_t  _gas_left,
int64_t  _gas_refund,
const evmc_address _create_address 
)
inlineexplicitnoexcept

Creates the result of contract creation.

Parameters
_status_codeThe status code.
_gas_leftThe amount of gas left.
_gas_refundThe amount of refunded gas.
_create_addressThe address of the possibly created account.

Definition at line 376 of file evmc.hpp.

380 : evmc_result{make_result(_status_code, _gas_left, _gas_refund, nullptr, 0)}
381 {
382 create_address = _create_address;
383 }
evmc_address create_address
The address of the possibly created contract.
Definition: evmc.h:465

◆ Result() [4/5]

evmc::Result::Result ( const evmc_result res)
inlineexplicitnoexcept

Converting constructor from raw evmc_result.

This object takes ownership of the resources of res.

Definition at line 388 of file evmc.hpp.

388: evmc_result{res} {}

◆ ~Result()

evmc::Result::~Result ( )
inlinenoexcept

Destructor responsible for automatically releasing attached resources.

Definition at line 391 of file evmc.hpp.

392 {
393 if (release != nullptr)
394 release(this);
395 }
evmc_release_result_fn release
The method releasing all resources associated with the result object.
Definition: evmc.h:455

◆ Result() [5/5]

evmc::Result::Result ( Result &&  other)
inlinenoexcept

Move constructor.

Definition at line 398 of file evmc.hpp.

398 : evmc_result{other}
399 {
400 other.release = nullptr; // Disable releasing of the rvalue object.
401 }

Member Function Documentation

◆ operator=()

Result & evmc::Result::operator= ( Result &&  other)
inlinenoexcept

Move assignment operator.

The self-assignment MUST never happen.

Parameters
otherThe other result object.
Returns
The reference to the left-hand side object.

Definition at line 409 of file evmc.hpp.

410 {
411 this->~Result(); // Release this object.
412 static_cast<evmc_result&>(*this) = other; // Copy data.
413 other.release = nullptr; // Disable releasing of the rvalue object.
414 return *this;
415 }
~Result() noexcept
Destructor responsible for automatically releasing attached resources.
Definition: evmc.hpp:391

◆ raw() [1/2]

const evmc_result & evmc::Result::raw ( ) const
inlinenoexcept

Access the result object as a const referenced to evmc_result.

Definition at line 421 of file evmc.hpp.

421{ return *this; }

◆ raw() [2/2]

evmc_result & evmc::Result::raw ( )
inlinenoexcept

Access the result object as a referenced to evmc_result.

Definition at line 418 of file evmc.hpp.

418{ return *this; }

◆ release_raw()

evmc_result evmc::Result::release_raw ( )
inlinenoexcept

Releases the ownership and returns the raw copy of evmc_result.

This method drops the ownership of the result (result's resources are not going to be released when this object is destructed). It is the caller's responsibility having the returned copy of the result to release it. This object MUST NOT be used after this method is invoked.

Returns
The copy of this object converted to raw evmc_result.

Definition at line 431 of file evmc.hpp.

432 {
433 const auto out = evmc_result{*this}; // Copy data.
434 this->release = nullptr; // Disable releasing of this object.
435 return out;
436 }

Member Data Documentation

◆ create_address

evmc_address evmc_result::create_address

The address of the possibly created contract.

The create address may be provided even though the contract creation has failed (evmc_result::status_code is not EVMC_SUCCESS). This is useful in situations when the address is observable, e.g. access to it remains warm. In all other cases the address MUST be null bytes.

Definition at line 465 of file evmc.h.

◆ gas_left

int64_t evmc_result::gas_left

The amount of gas left after the execution.

If evmc_result::status_code is neither EVMC_SUCCESS nor EVMC_REVERT the value MUST be 0.

Definition at line 405 of file evmc.h.

◆ gas_refund

int64_t evmc_result::gas_refund

The refunded gas accumulated from this execution and its sub-calls.

The transaction gas refund limit is not applied. If evmc_result::status_code is other than EVMC_SUCCESS the value MUST be 0.

Definition at line 413 of file evmc.h.

◆ output_data

const uint8_t* evmc_result::output_data

The reference to output data.

The output contains data coming from RETURN opcode (iff evmc_result::code field is EVMC_SUCCESS) or from REVERT opcode.

The memory containing the output data is owned by EVM and has to be freed with evmc_result::release().

This pointer MAY be NULL. If evmc_result::output_size is 0 this pointer MUST NOT be dereferenced.

Definition at line 427 of file evmc.h.

◆ output_size

size_t evmc_result::output_size

The size of the output data.

If evmc_result::output_data is NULL this MUST be 0.

Definition at line 434 of file evmc.h.

◆ status_code

enum evmc_status_code evmc_result::status_code

The execution status code.

Definition at line 397 of file evmc.h.


The documentation for this class was generated from the following file: