Questions tagged [delegatecall]
https://docs.soliditylang.org/en/v0.8.12/introduction-to-smart-contracts.html?highlight=delegatecall#delegatecall-callcode-and-libraries
219 questions
2
votes
1
answer
21
views
Does delegate calling to a non-payable function result into a revert?
I have a payable function that takes an array of call datas as input, to which it delegate calls one-by-one:
function batch(bytes[] calldata calls) external payable override {
uint256 count = ...
0
votes
1
answer
18
views
Cannot delegatecall a nonpayable function from a payable context?
I'm wondering why it always reverts when I delegatecall a non-payable function from a payable context when the msg.value is not 0.
Simple code below:
contract Trial {
function magicNumber42() ...
1
vote
1
answer
51
views
"DELEGATECALL" with value
How is it possible that "DELEGATECALL" with a non-zero value?
Example:
https://sepolia.etherscan.io/tx/0xd697d2db1494197496a8e6312c8295131a1df66bdeafd29be85361f2318832ad/advanced#internal
...
0
votes
1
answer
58
views
Reason for Checking `msg.sender == _msgSender()` in OpenZeppelin's MulticallUpgradeable Contract
In the OpenZeppelin::MulticallUpgradeable contract, there's a validation that checks msg.sender == _msgSender(). Considering that msg.sender and _msgSender() typically return the same value, why is ...
0
votes
1
answer
28
views
Is delegatecall to another contract really same as calling the function as if it were the part of calling contract?
When a contract makes a delegatecall, the code at the target address is executed in the context of the calling contract. This means that the storage, state variables, and functions of the calling ...
0
votes
2
answers
47
views
Utilize delegatecall to set values for struct fields
There are two smart contracts, A and B. They have identical slot numbers for their state variables. I need to assign some values to a struct in B by delegatecalling the fillDev() function of A. ...
0
votes
1
answer
162
views
Delegatecall failing 'could not coalesce error'
I'm trying to set a message to my Contract setmsg through a proxy contract using delegatecall.Using hardhat.
getting this error:
error: {
code: -32603,
message: "Error: VM Exception ...
1
vote
1
answer
237
views
Payable multi-delegatecall
I have a code of multi-delegatecall like this:
function multicall(bytes[] calldata _data) external payable returns(bytes[] memory _results) {
_results = new bytes[](data.length);
for (uint256 ...
0
votes
1
answer
19
views
Identifying delegatecalls to a target contract
A contract I am auditing (contract A) is being used via delegate call by another contract. I suspect there may be more contracts using this code as well in the same manner but I cannot prove it.
Is ...
0
votes
0
answers
14
views
Can a contract call a proxy via delegatecall in a function?
I suppose this is not possible as the proxy contract code would try to retrieve the implementation code from the original contract storage.
0
votes
0
answers
54
views
Access imported contract's function on behalf of another contract using delegatecall
So I have two contracts. the firt one is a contract that imports a token
import {testToken} from "./testToken.sol";
testToken public token;
and has this functionality
AddressUpgradeable....
0
votes
1
answer
39
views
How to build a 3 contract structure with delegatecall
I'm looking for help to build an intermediate contract using delegatecall. My challenge would be with 3 contracts.
I need contract A to be the owner of Contract B, and contract B to have a ...
2
votes
0
answers
23
views
Why is `delegatecall` not working with simple example on quorum node?
Deploying these two contracts:
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
// NOTE: Deploy this contract first
contract B {
// NOTE: storage layout must be the same as contract A
...
0
votes
1
answer
35
views
Unable to change the storage using Delegate call
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Preservation {
// public library contracts
address public timeZone1Library;
address public timeZone2Library;
address public ...
1
vote
1
answer
203
views
How to change the storage using Delegate call
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Preservation {
// public library contracts
address public timeZone1Library;
address public timeZone2Library;
address public ...
3
votes
0
answers
69
views
`delegatecall` in batch call stops working as expected when changing the code slightly
I have the following function for batching multiple calls, which returns the result (success or not) and the return data for each corresponding call.
function callBatch(bytes[] calldata calls) public ...
1
vote
1
answer
290
views
is this how delegatecall works? what other ways are there keep msg.sender the same when a contract is interacting with a different contract? [duplicate]
I recently started development on a personal project, and one of the suggested methods to achieve what i want was using delegatecall. Essentially I have a main contract that the user interacts with ...
0
votes
1
answer
109
views
Determining if a smart contract is using delegatecall
Let's say that I have the bytecode of a smart contract deployed on ethereum (which I got with a call to eth_getCode).
How can I programmatically determine if this smart contract uses delegatecall ...
2
votes
2
answers
147
views
Solidity Proxy: why using initialiser instead of a constructor?
Why proxies can't read from the constructor?
1
vote
0
answers
28
views
Inheriting a contract to match state layout in a delegatecall
What is the best way to manage the state layout of a contract will exclusively be used via a delegatecall?
Let's say that there is a Parent contract that uses delegatecall on a Child contract. Within ...
0
votes
2
answers
112
views
Why we are using delegatecall?
As far as I understand is, Delegate is called to pass ETH from another contract.
In my perspective, it seems like a transaction goes through twice. Why we are using delegate call?
0
votes
1
answer
67
views
delegateCall to a function of an upgradeable contract (TransparentUpgradeable)
I have the following TransparentUgradeable contract on ArbitrumOne:
https://arbiscan.io/address/0x4582f67698843Dfb6A9F195C0dDee05B0A8C973F
I want to call the function depositTokenViaUsdc() from a ...
0
votes
1
answer
57
views
Execute ERC20 Approve outside of ERC20 contract
I am rewriting the solidty-by-example.org crowdfunding exercise.
IERC20 public immutable token;
function pledge(uint _id, uint _amount) external {
Campaign storage campaign = campaigns[_id];
...
2
votes
0
answers
557
views
How to interact with proxy contract with ethers and wagmi
I have an upgradable proxy contract that points to a specific contract. This is the contract in mumbai polygonscan => https://mumbai.polygonscan.com/address/...
2
votes
1
answer
246
views
How to setup Module without Safe transaction using setup function
As I understand to and data parameters used in the setupModules function, can help to execute a delegated call that makes modules setup on the Safe creation.
/// @dev Setup function sets initial ...
1
vote
1
answer
90
views
Read value from DelegateCall
I would like to implement a whitelist using AccessControl of openzeppelin. Let's say I have the following setup:
Contract A: It's doing some stuff but only for users that are whitelisted.
// SPDX-...
0
votes
1
answer
90
views
Using delegateCall without knowing the called contract's address
I am fairly new to Solidity and slowly starting to grasp its ecosystem :-)
I have a question about using delegateCall: How do I ensure that I call exactly the contract I want to call?
Let's assume I ...
0
votes
1
answer
104
views
Is "msg.sender.token1().gas(msg.gas)" too low-level call?
Context :
I decompiled this contract(https://bscscan.com/address/0x5cb11ce550a2e6c24ebfc8df86c5757b596e69c1#code) which is the attacker's smartcontract that hacked MEV-bot. You can check the ...
1
vote
1
answer
191
views
Does delegatecall also works for calling other contract's constructor?
I want to call other contract's constructor, but I'm not sure if the delegatecall function will work for that case. I have no way to test it out on Remix, because my Remix seem to not work with even ...
2
votes
2
answers
440
views
If a solidity library function is marked as public does it inline the function or call it with a delegatecall from the calling contract?
I am aware that a solidity library function marked as external will be deployed separately and called with delegatecall from the calling contract. Whereas a function marked as internal will just be ...
5
votes
2
answers
713
views
Preserving visibility "view" of a method using delegate call to a view method
I am using a delegate call inside a view function to a view function in the implementation contract
The compiler throws an error meaning that the delegate call can change the state, therefore, can not ...
2
votes
1
answer
260
views
check if a DELEGATECALL has taken place during the transaction
I know how to check if a current contract's function is been called using CALL or DELEGATECALL (by comparing address(this) to the contract's address that must have been previously saved as an ...
2
votes
1
answer
2k
views
Who is msg.sender in a nested delegatecall chain?
Who is the msg.sender in emitted event by calling callMe method on contract D?
pragma solidity 0.8.10;
contract A {
event LogMsgSender(address who);
function callMe() public {
emit ...
2
votes
0
answers
598
views
Solidity assembly code - calldatacopy, delegatecall
I have been trying to understand how assembly code works,spending lots of hours, but I could not.
Please help me
Basically, I am digging into a proxy contract, and I do not really understand ...
0
votes
1
answer
544
views
Can a 3rd party smart contract transfer user funds without approval by using delegatecall('transfer', to, amount)?
I'm creating a contract where the user would transfer X amounts of tokens A and B to my smart contract for a task. The problem with this is that in principle, the user would have to sign and send 3 ...
0
votes
1
answer
63
views
Can a user transfer X and Y tokens to a smart contract in a single transaction/interaction with the smart contract?
I'm trying to develop a contract to which users would send certain amounts of tokens A and B to the smart contract. Easiest/obvious way to do it would be to do several transactions in this order:
...
2
votes
4
answers
1k
views
How can I create a Factory of TransparentUpgradeableProxy?
I have the following code for a Factory that creates instances of a contract that is Upgradeable. I understand that, in order to achieve this, one of the options I have is to use ...
0
votes
1
answer
85
views
How call() function works in solidity?
Learning call() function in Solidity, I read that we use call() only when we don't know the ABI of the called contract and we don't know its source code.
Below I have an example, but it seems we DO ...
4
votes
1
answer
221
views
Low level delegatecalls from contract to deployed library issues
I'm looking to make low-level delegatecall to a library that can be changed via a setter on the contract(see code below). Within the library, I am looking to make state changes to the calling contract....
0
votes
2
answers
25
views
How to make a delegatecall to a already deployed library of which you have the address
The below code fails when calling foo() on TestContract. The adaptedLib as been set to the right address. How do you make a delegatecall to a lib correctly?
contract TestContract {
address public ...
0
votes
0
answers
33
views
Low level delegatecall to a lib does not change state in calling contract
In the code bellow when calling foo the storage of TestContract gets not changed. Expected behaviour to my understanding is that state.a is set to 5. The arg passed to the library function foo is a ...
0
votes
1
answer
118
views
What are the benefits of using Opensea's Creature Factory?
link : https://stonk.industries/how-to-create-your-own-nft-using-the-opensea-creatures-template/
To Factory or not to Factory
that is the question
This repo also includes a factory which is just ...
2
votes
1
answer
674
views
The low-level functions call, delegatecall and staticcall return true as their first return value if the account called is non-existent
According to the official Solidity documentation:
The low-level functions call, delegatecall and staticcall return true as their first return value if the account called is non-existent, as part of ...
1
vote
0
answers
46
views
How can timeZone1Library value be changed to address of Attack code? (Ethernaut #16 Preservation)
I've been practicing Ethernaut #16 Preservation. Everything is okay and I understood what delegatecall is. But, I don't get why timeZone1Library can be changed when we pass deployed attack address as ...
0
votes
2
answers
1k
views
How to ".call" a function of another contract which uses ".call"
So, I'm learning advanced smart contract development. Two days ago, I learned about Reentrancy attacks and then I also created two contracts Protocol.sol (vulnerable contract) + Hacker.sol (attacker ...
1
vote
0
answers
46
views
How to decode DSProxy input data
I'm trying to debug a tx made through a DSProxy deployed on Polygonscan, but I'm having a difficult time since the _data part of the DSProxy function input is ABI-encoded. I would have to comb through ...
0
votes
1
answer
258
views
testing in hardhat delegatecall returns invalid values
I'm trying to test if the delegatecall works fine, but I got an unwanted result.
contract CallerContract{
uint256 public value;
address public sender;
string public name;
...
0
votes
1
answer
84
views
Propose delegatecall via the safe-apps-sdk
Is the safe-apps-sdk only meant to be used when we don't need to propose a delegatecall to the safe?
It seems that the safe-apps-sdk uses MultiSendCallOnly.sol.
Is it possible to customize the ...
0
votes
0
answers
63
views
How to delegate call from one contract to another contract in different blockchain
My proxy contract and implementation contract are in different blockchains. Can i use delegate call?
1
vote
1
answer
311
views
How to use the factory pattern when the child is ownable?
I'm trying to reason how a factory can make calls to a child contract that is owned by an EOA.
The goal of this project is to make a StoreFactory contract that allows anyone to deploy their own Store ...