Skip to main content
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 ...
Ismael's user avatar
  • 30.3k
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 ...
hroussille's user avatar
  • 7,901
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 ^...
Mila A's user avatar
  • 1,554
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() ...
Sami Bouchnafa's user avatar
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(...
user115239's user avatar
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); ...
Jeremy Then's user avatar
  • 4,639
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 ...
Jeremy Then's user avatar
  • 4,639
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.
0xSanson's user avatar
  • 3,927
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 ...
phaze's user avatar
  • 1,635
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. ...
Richard's user avatar
  • 5,144
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).
clement's user avatar
  • 4,352

Only top scored, non community-wiki answers of a minimum length are eligible