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 328 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 348 of file evmc.hpp.

353 : evmc_result{make_result(_status_code, _gas_left, _gas_refund, _output_data, _output_size)}
354 {}
constexpr auto make_result
Alias for evmc_make_result().
Definition: evmc.hpp:322
The EVM code execution result.
Definition: evmc.h:416

◆ 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 361 of file evmc.hpp.

364 : evmc_result{make_result(_status_code, _gas_left, _gas_refund, nullptr, 0)}
365 {}

◆ 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 373 of file evmc.hpp.

377 : evmc_result{make_result(_status_code, _gas_left, _gas_refund, nullptr, 0)}
378 {
379 create_address = _create_address;
380 }
evmc_address create_address
The address of the possibly created contract.
Definition: evmc.h:486

◆ 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 385 of file evmc.hpp.

385: evmc_result{res} {}

◆ ~Result()

evmc::Result::~Result ( )
inlinenoexcept

Destructor responsible for automatically releasing attached resources.

Definition at line 388 of file evmc.hpp.

389 {
390 if (release != nullptr)
391 release(this);
392 }
evmc_release_result_fn release
The method releasing all resources associated with the result object.
Definition: evmc.h:476

◆ Result() [5/5]

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

Move constructor.

Definition at line 395 of file evmc.hpp.

395 : evmc_result{other}
396 {
397 other.release = nullptr; // Disable releasing of the rvalue object.
398 }

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 406 of file evmc.hpp.

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

◆ 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 418 of file evmc.hpp.

418{ return *this; }

◆ raw() [2/2]

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

Access the result object as a referenced to evmc_result.

Definition at line 415 of file evmc.hpp.

415{ 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 428 of file evmc.hpp.

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

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 486 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 426 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 434 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 448 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 455 of file evmc.h.

◆ status_code

enum evmc_status_code evmc_result::status_code

The execution status code.

Definition at line 418 of file evmc.h.


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