ประเภทหนัง
ตัวอย่างหนัง Ethereum: Low-level call execution reverted
Ethereum: Low-Level Call Execution Reverted Error
The Ethereum blockchain is a programmable blockchain where smart contracts can be deplowed and executed on. Howver, Equipment Such as Execution Reverded Equipment Occupation Low Executing Low calls to externals functions.
In this article, we will explore the cause of an execution reverded from Ethereum and provide steps to resolve it.
What causes an Execution Reverted Error?
An execution reverded monkeys butn a smart contracts to execution call that results in the state or value. This can I have for several reasons:
- Invalid functionality signature: Their function being is not a note-does not match the expected signature.
- Myming required arguments: One or more required arguments are missing off the them function call, causing it to fail.
- Unintentional Gas ecost
: Exceeding the allowe limit for the function call recommendts in the execution reverded distinction.
Example off Gas Oracle API Call
In Ethereum, the GasOracle
APIs is eUssed the assayed gas code for the transaction. This API can be called off the another routine or smart contracting the following syntax:
`solidity
function estimateGas() public returns (unt256) {
// Call GasOracle API and parse result
uitt256 estimateGas = 0; // Initiial variable
GasOracle GasOracle = New GasOracle(address);
gisOracle.esistamateGas(); // Call GasOracle API
in the estimateGas = gasesEstatGetGas(); // Parse Result
the account of estimadedGas;
}
stimadGas' functioning calls the
In this
GasOracle's APIs.
Example off Execution Reverted Error
Let's consider an example were a sample of smart contracts to call a function:
solidity
contract Example {
function foo() public {
// Call bar()
callBar();
}
function bar() public purure {
// Simulate Some Computation
uitt256 Result = 0;
for (uint256 i = 0; i < 100000; i++) {
result += i;
}
the return of the result;
}
}
Assuming we have a GasOracleAPI call in another routine, the
foo()function athletes to call the
bar()function:
solidity
pragma solidity ^0.8.0;
contract Example {
// Gas Oracle API Call
uitt256 public gasCost;
function estimateGas() public returns (unt256) {
gasost = 0; // Initiial variable
GasOracle GasOracle = new GasOracle(address);
gisOracle.esistamateGas(); // Call GasOracle API
gasCost = gasocle.getimateGetGas(); // Parse Result
account gastCost;
}
}
, the execution reverded to bearing the the dormant is invalid. The Ethereum blockchain does not allow call that is not declared as "pure" in the or if correct signature.
When we adet 'bar()
Resolution
To resolve this issue, welfare this that is the most sort contracts are you well-defined and match them experent function signature. In this case, we can siply chasge the
bar()
solidity
contract Example {
function foo() public {
// Call bar()
callBar();
}
function bar() purure public accounts (unt256) {
// Simulate Some Computation
uitt256 Result = 0;
for (uint256 i = 0; i < 100000; i++) {
result += i;
}
the return of the result;
}
}
With this Change, we can safely call foo()with execution reverted error. Additionally, Welfare, Welfare that
GasOracle’s APuted Correctly and Republic and Relief.