6
votes
Accepted
Yul/Inline Assembly: Revert with a custom error message
This kind of code:
require(_amountToRaise > 0, "Amount to raise smaller than 0");
Produces revert with bytes equivalent to calldata of the following method:
function Error(string memory ...
4
votes
Yul/Inline Assembly: Revert with a custom error message
First I think you mixed some hexadecimal notation with some decimal ones, the correct decomposition should be :
if iszero(gt(_amountToRaise, 0)) {
mstore(0x80, shl(229, 4594637))
mstore(0x84, ...
3
votes
Accepted
what is the correct way to define a custom error
If it's defined outside you can share it among your contracts and maintain consistency in your code, other than that I don't think there are any other relevant differences in deployment or execution ...
3
votes
Is it possible to reverse the gas used in case of using revert?
Unfortunately, it is not possible to refund gas that has already been used in a transaction on the Ethereum blockchain. Once gas is consumed in a transaction, it cannot be refunded or reclaimed. This ...
2
votes
Accepted
What are the two arguments in revert opcode?
offset is the starting position of the desired return data in memory and size is the size of the desired return data in memory. Offset and size are used to designate where the return data starts (...
2
votes
to.be.revertedWith("Error Message ") returning failed test despite custom error matching "Error Message"
I think revertedWith looks for a string message as we can see here on hardhat documentation
And... the revertedWithCustomError, for a custom error.
So this behavior is correct IMO, since you're using ...
2
votes
Accepted
Is there a way to handle `abi.decode` errors?
While writing the question, I was able to find a solution.
ATTOW this is already a feature request. See issue-10381 and issue-10933 on github. Thankfully one of the core members mentioned in this ...
2
votes
swapExactTokensForTokens error TRANSFER_FROM_FAILED even after approval?
You either do not have enough allowance, however it seems that you give allowance to the router, check if the number is actually in the right format (wei). Check is the owner of the allowance is the ...
2
votes
external call to non-existing address returns success
That's a normal behavior.
This is because low level calls returns true if the address doesn't exist or even if you passed a zero address.
That's why it is always recommended to put checks for zero ...
2
votes
Accepted
How can I decode a low-level return data from a reverting call?
Just found another solution that is much more gas efficient, as it uses a native Error function to parse the response:
{
(bool success, bytes memory response) = address(proxy).call(abi....
1
vote
How can I decode a low-level return data from a reverting call?
abi.decode() needs to receive ABI-encoded data without signatures, but revert() returns a standard Error(string), resulting in ABI-encoded signature+data.
So, you just need to remove the signature ...
1
vote
Accepted
External call recipient can consume all transaction gas
When making external calls in Solidity, the default behavior is to forward all available gas to the recipient contract, This means that the recipient contract can consume the entire gas limit of the ...
1
vote
Contract reverts at deploy when sending 2 ethers
If you want to pass the value while deployment, then you need to make the constructor() as payable, like this:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
contract FundMe {
...
1
vote
Accepted
How to get revert message in Web3js?
There's a better way to do this in Web3.js.
// index.js
const { Web3 } = require("web3");
const rpcProvider = 'https://rpc.ankr.com/polygon_mumbai'; // 'https://polygon-testnet.public....
1
vote
Accepted
Find out revert/error reason
The Tenderly debugger for the transaction shows that it's because the incorrect amount was sent with the call.
For accessibility, here is the code from the screenshot (a redundant comment is left out ...
1
vote
Low-level function call to other contract is causing revert with correct function selector
You don't have to set the value to 0 when you call the go() function .
call low level function returns two values , a boolean and bytes . Try to
store these two values in variables .
function go() ...
1
vote
Revert inside a for loop
Yes, a revert within a loop inside a function triggers a full function revert due to its stack-based execution model, rolling back all changes made within the function.
1
vote
MetaMask doesn't catch ERC20 reverts
This is the MetaMask feature/bug. To understand what happens: MetaMask has the built-in page for sending tokens: send.js and this is a separate page comparing to submitting the raw transaction from a ...
1
vote
Accepted
Why doesn't this try/catch block catch the revert in `asset.symbol`?
try..catch doesn't catch the boundary exceptions, just the inner method call. Exactly that, what you have mentioned:
checks if address is not void
checks if extcodesize exists
--checks if method ...
1
vote
Accepted
Solidity: call() with bubbling the revert reason
Here's a code snippet that checks if a call reverts, loads the revert string message if true and raises it correctly.
Side note: Using abi.encodePacked can lead to incorrect input encoding if you are ...
1
vote
I can't deploy a contract with payable function
I think you are trying to send the Ether while you are deploying the contract.
First, deploy the smart contract using the Deploy button, then call the Fund() function specifying the amount you want to ...
1
vote
Error: call revert exception (method="admin()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION)
It looks like error is caused by the admin() function because its not being properly handled by proxy contract. To resolve this, modify admin() function in the Proxy contract to include ifAdmin ...
1
vote
Accepted
Why does Remix does not show the description of the error anymore?
I have observed this. It got really bad to correct errors and debug now. Before, everything was better. That update they made was really bad.
They made this update and a solution (mandatory) is to ...
1
vote
Understanding eth_sendBundle, eth_sendPrivateTransaction and eth_sendRawTransaction
eth_sendPrivateTransaction basically a simplified way of using eth_sendBundle. You don't have to add more transactions than 1 and you don't have to resend the transaction every block. They will send ...
1
vote
Why Does This Chainlink Example Code Revert?
It is because you used the legacy version of the VRF Consumer smart contract, which is deprecated. You should migrate to VRFv2, you can grab the example consumer contract from the Chainlink official ...
1
vote
Accepted
ValueError:Gas estimation failed:'execution reverted'.This transaction will likely revert.If you wish to broadcast,you must set the gas limit manually
I don't know about the exact logic of your smart contract but the revert is caused by accessing an element out of bound from your rprice array.
When you deploy the contract, at the beginning rprice ...
1
vote
I'm trying to reverse an array but the transaction keeps getting reverted even though the logic seems right. Can someone help me out?
There are number of syntax issues in the code you posted.
But this should help;
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;
contract RevertArray {
function reverseArray(...
1
vote
I'm trying to reverse an array but the transaction keeps getting reverted even though the logic seems right. Can someone help me out?
So, two things:
you need to change how you declare your arr2
in your while loop, i gets to 0 and goes into the loop where you do i-- so you are doing '0 - 1' and you underflow, which reverts your ...
1
vote
Accepted
Error: VM Exception while processing transaction: reverted with reason string 'Didn't send enough!' on testing contract
I got this error because in my fundMe smart contract i used revert error in require is different than script, they both should be same.
In require it is "Didn't send enough!" while in revert ...
1
vote
Accepted
Basic For loop fails in Solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract ForLoop {
function getOwnedTokens() public pure returns (uint[] memory) {
uint numberOfOwnedTokens = ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
revert × 60solidity × 37
error × 6
hardhat × 6
web3js × 5
contract-development × 5
remix × 5
assembly × 4
require × 4
transactions × 3
gas × 3
javascript × 3
evm × 3
uniswap × 3
testing × 3
solidity-0.8.x × 3
try-catch × 3
custom-errors × 3
foundry × 3
contract-invocation × 2
ganache × 2
unittesting × 2
overflow × 2
function × 2
truffle × 1