3
votes
Encode function signature with callback function as parameter in Solidity
From solidity documentation:
If external function types are used outside of the context of Solidity, they are treated as the function type, which encodes the address followed by the function ...
2
votes
Accepted
How do I pass a struct as an argument in delegatecall to a proxy library?
You just encountered one of the caveats of library ABI encoding. You can read about it here. Essentially, this line related to libraries function selectors is the explanation :
Non-storage structs ...
1
vote
abi.decode() does not accept "address payable" as type
I didn't find a documented way to decode an array address payable[] implicitly, however the closest equivalent I can think of is the following:
// SPDx-License-Identifier: UNLICENSED
pragma solidity ^...
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
'Address: low-level call failed'
your issue is with the space between parameters in "approve(address, uint256)".
Instead of ...
bytes memory data = abi.encodeWithSignature(
"approve(address, uint256)", address(...
1
vote
Accepted
Encoding a bytes array with function signature: "TypeError: This type cannot be encoded."
What Solidity version are you using?
I'm using Solidity version 0.8.16 and it's working fine for me.
Check:
pragma solidity ^0.8.16;
contract DoStuff {
event DidStuff(uint256 timestamp);
...
1
vote
Call fails when I send 2 params to other contract with abi?
The problem is that you are adding an space to the signature parameters, hence, it produces a different signature.
Take a look at this code:
function encodeWithSignatureWithSpaceInParams() public pure ...
1
vote
Accepted
Call fails when I send 2 params to other contract with abi?
You should use "sumTwoParams(uint256,uint256)" (no whitespaces after ,) when encoding the signature.
1
vote
Accepted
What is the difference between encodeWithSelector and encode?
The normal abi.encode encodes values according to the abicoder. A bytes4 value is padded to 32 bytes
...
1
vote
Accepted
Encode function data with value
I am assuming you want to send along ETH with your call when you talk about "sending value". You can specify this on the call with {value: 1000000 }.
This is specified in the Solidity docs.
...
1
vote
Accepted
setting value using address.call() doesn't works
Just increase the allocated gas from 5000 to 10000 in the call inside the testCallBar function and it will work.
In fact, setVal is more expensive than foo as it updates a state variable (bar).
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
abi.encodewithsignature × 19solidity × 15
abi × 5
delegatecall × 2
abiencoderv2 × 2
address.call × 2
blockchain × 1
remix × 1
addresses × 1
contract-debugging × 1
uniswap × 1
struct × 1
ethers.js × 1
hash × 1
bytecode × 1
chainlink × 1
bytes × 1
keccak × 1
library × 1
verify × 1
data-types × 1
encoding × 1
eth-call × 1
callcode × 1
msg.sender × 1