Questions tagged [delegatecall]
https://docs.soliditylang.org/en/v0.8.12/introduction-to-smart-contracts.html?highlight=delegatecall#delegatecall-callcode-and-libraries
214
questions
0
votes
1
answer
14
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
15
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
0
answers
16
views
Solidity contract using delegation working well in remix vm shanghai environment but failing in our local node
We have a contract that use a delgatecall to finally register a node in a mapping array (nodeDB contract).
This contracts works correctly if we executed in remix vm shanghai environment but if we ...
0
votes
1
answer
17
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
26
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
47
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
29
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
55
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
27
views
Solidity Proxy: why using initialiser instead of a constructor?
Why proxies can't read from the constructor?
0
votes
0
answers
17
views
How can one OZ Transparent Proxy access data from another OZ Transparent proxy?
Scenario:
I have two proxies:
Root Proxy, this is created during deployment
Secondary proxies, this is created at start of each transaction, and is initialized with the context of the transaction
...
1
vote
0
answers
17
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
80
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
26
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
28
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];
...
0
votes
0
answers
38
views
How to setup Module without Owner in Gnosis setup function using Smart Contract
I am trying to setup module by delegate call in setup function of Safe. In my custom factory Smart Contract
// Create Gnosis Safe wallet using ProxyFactory
address moduleImplementationAddress = ...
0
votes
0
answers
14
views
Need help with delegate call or other possible solutions to get ownership of a contract
So I'm in a bit of a situation. Here's a short description of it:
SmartContractA is a staking contract which is owned by SmartContractB
SmartContractB has wrong address of smartContractA in its ...
1
vote
0
answers
345
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/...
1
vote
1
answer
119
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 ...
2
votes
1
answer
186
views
How is the data parameter constructed in the swap function of 1inch AggregationRouterV5
The swap function in AggregationRouterV5 is like this
function swap(
IAggregationExecutor executor,
SwapDescription calldata desc,
bytes calldata permit,
bytes calldata data
)
...
0
votes
0
answers
80
views
Ethernaut Puzzle Wallet
Link: https://ethernaut.openzeppelin.com/level/0x4dF32584890A0026e56f7535d0f2C6486753624f
I know that this exploit works but can someone explain why calling PuzzleProxy.approveNewAdmin(player_address) ...
1
vote
1
answer
57
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
44
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
76
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
131
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 ...
0
votes
2
answers
132
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
433
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
124
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 ...
1
vote
1
answer
884
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 ...
1
vote
0
answers
373
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
324
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
50
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
874
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
79
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
191
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
24
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
32
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
107
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
476
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
728
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
32
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
206
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
64
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
57
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
213
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 ...
1
vote
0
answers
201
views
UUPS upgradeable contract call fails with delegatecall error when calling newly added functions
I created an upgradeable contract adhering to the UUPS standard following this guide here. I then added some new functions, deployed the upgrade using the upgrades plugin upgrades.prepareUpgrade() ...
3
votes
1
answer
299
views
Delegatecall not working
I have deployed the following smart contract: 0x016d87b8c98e6ad0991d128CddA435FAfbC06792
//SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
contract Proxy {
uint256 public count;
address ...
1
vote
1
answer
135
views
Expected primary expression in byte casting
I have a contract (Implementation.sol) which delegatecalls the other contract (Attacker.sol) to selfdestruct. When I try to compile the Implementation.sol on Remix, I receive Expected primary ...
0
votes
0
answers
201
views
EOA delegating call authority to a contract to interact with another contract
Actually, I want my contract (say A) to interact with a project's contract (say B).
But, contract B's author has restricted calls by any contract. So with this, only one option is left i.e. an EOA ...
2
votes
0
answers
367
views
Exception while processing transaction: reverted with reason string 'Address: low-level delegate call failed'
I have the following function inside my Registry.sol contract:
function createOrganizerProxy(bytes32 organizationName)
public
payable
returns (address)
{
require(!isTaken[...