Questions tagged [delegatecall]

https://docs.soliditylang.org/en/v0.8.12/introduction-to-smart-contracts.html?highlight=delegatecall#delegatecall-callcode-and-libraries

Filter by
Sorted by
Tagged with
1 vote
0 answers
14 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
17 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; ...
  • 103
0 votes
1 answer
15 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 ...
  • 1
0 votes
0 answers
15 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
0 votes
1 answer
34 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 ...
  • 13
1 vote
0 answers
13 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() ...
2 votes
1 answer
63 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
35 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 ...
  • 13
0 votes
0 answers
17 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 ...
  • 131
0 votes
0 answers
10 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[...
0 votes
1 answer
34 views

How do I call delegatecall and how do I change it to use the following contract to call?

a is the contract that contains the delegate call, b is the calling contract, I wonder if this B contract can be used for another contract also which contains delegate call? In the end, I'm interested ...
  • 31
0 votes
0 answers
17 views

How to call a function's Contract B from a contract address and not a personal EOA account?

I"m working on a proxy implementation and I already have a proxy contract with 2 setters to modify the implementation the proxy delegates the calls to. setPendingImplementation ...
0 votes
2 answers
236 views

Fastest way to find the function in a contract from it's selector?

Let's say I have a function selector: 0xa9059cbb And I have a contract as such: // SPDX-License-Identifier: MIT pragma solidity ^0.8.7; contract CallAnything { function balanceOf(address ...
0 votes
0 answers
20 views

Does anyone know what is the purpose of "this;" at the end of the function [duplicate]

// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Delegate { address public owner; constructor(address _owner) public { owner = _owner; } function pwn() public { ...
0 votes
1 answer
90 views

What exactly is each parameter for assembly delegatecall?

I've been searching everywhere but I'm still not clear what each of the parameters are for delegatecall. What I have found is this delegatecall(g, a, in, insize, out, outsize), where g is gas and a is ...
  • 35
0 votes
1 answer
212 views

What is the difference between encodeWithSelector and encode?

I've been messing around with the abi.encode... functions and I think I have a good grasp of the differences, except abi.encode and abi.encodeWithSelector. Because, they give similar but slightly ...
  • 35
1 vote
2 answers
133 views

Why is delegatecall calling the fallback function?

I made two simple contracts to test delegatecall on remix: contract Delegate{ uint public x; function add(uint a, uint b)public{ x = a + b; } fallback() external{ ...
  • 35
0 votes
1 answer
164 views

How do I pass a struct as an argument in delegatecall to a proxy library?

I am trying to call the buyAssetsForEth function in the OpenSeaMarketV2 library using delegatecall as follows: pragma solidity 0.8.4; contract Owned { address public owner; constructor(...
1 vote
1 answer
118 views

Is there a way to check if a call is a call or a delegatecall?

I want to add a modifier to one of my function that checks wether the function call is a call or a delegatecall? Is there any way to figure that out? May be with some assembly?
  • 56
0 votes
1 answer
210 views

delegate call from a fallback function using msg.data doesn't work

Please look into the following 3 contracts: // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.7; contract implementationProxy { uint public a; uint public b; address owner; ...
0 votes
0 answers
15 views

Why this delegatecall -> call tx is not completing?

I wish I had a better title for this but I simply do not know what is going on. The function simply stops during _mint function at _balances[account] = oldAccountBalance.add(amount); My goal is to ...
  • 183
1 vote
1 answer
33 views

How can i foward funds swaped from 0x api quotes in the same transaction

ideally i will like to add more logic (like fowarding funds or fees) to the quote.data before letting a user send the transaction to the blockchain.
  • 11
0 votes
0 answers
33 views

0x fillQuote fails on mainnet fork. i am sending a delegate call (i want to save transaction context) to the 0x proxy contract but transactions fail

function fillQuote( // The `sellTokenAddress` field from the API response. IERC20 sellToken, // The `buyTokenAddress` field from the API response. IERC20 buyToken, // The `...
  • 11
0 votes
0 answers
10 views

Changing msg.value

Is there any way to change msg.value between calls (or delegatecalls)? For example: A --delegatecalls(msg.value=0)--> B -->delegatecall(msg.value=1) --> C where some logic would happen in B ...
  • 379
0 votes
1 answer
122 views

fallback not executing

I have a test project with proxy pattern (fallback/delegate call). The purpose is to have upgradeable contracts. Here is the proxy contract: // SPDX-License-Identifier: MIT pragma solidity 0.8.13; ...
  • 105
1 vote
1 answer
67 views

Assembly vs solidity delegatecall

Is there a real difference nowadays, performance-wise, between using assembly delegatecall and the high-level solidity version? I know that in the past assembly was used so you could get the returned ...
  • 379
2 votes
2 answers
657 views

Can ERC-20 token transfers have re-entrancy?

I understand that re-entrance attack can happened when you send ETH, because of fallback() function. But in ERC20 transfer there is no call for fallback, so I wonder if there's a way to make re-...
  • 21
0 votes
1 answer
11 views

Delegatecall reverting after adding a second argument

solidity 0.8.3; I am trying to implement delegatecall, and I created a simple test within my contracts. function f(uint256 _testInt) public view returns(uint256 test) { test = _testInt + 1; ...
  • 3
1 vote
1 answer
70 views

Contract A delegatecall function in contract B which calls function in contract c. msg.sender for function in contract c?

If Function in contract A delegatecall function in contract B which calls function in contract C. What will be the msg.sender for function in contract C?
1 vote
2 answers
695 views

How to use Proxies in Ethers?

I'm trying to use Proxies in Ethers. My Solidity file: //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy....
0 votes
1 answer
321 views

delegateCall in Solidity understanding case

pragma solidity ^0.8.10; /* HackMe is a contract that uses delegatecall to execute code. It it is not obvious that the owner of HackMe can be changed since there is no function inside HackMe to do so....
  • 3
0 votes
1 answer
46 views

Events in Chained Fallback Function Cause VirtualMachineError

I’m working on an upgradeable contract that uses fallback functions with inline assembly delegatecall and call calls (using calldatacopy and returndatacopy) to route internal and external function ...
  • 136
1 vote
1 answer
264 views

Delegatecall failing

I have this second-layer delegatecall (delegatecall on a contract that already did delegatecall) that continues to fail even after checking all the main reasons why it could fail (storage layout, uint ...
  • 379
0 votes
1 answer
51 views

How do you manipulate a storage struct array with an external library function?

Basic pseudocode mockup of my problem import libraryB; contract A{ struct Person{ string Name; uint age; } Person[] public Party; Party[0] = (Alice, 30); libraryB.addAgeToPerson(Party[0], 1) } ...
0 votes
1 answer
101 views

solidity delegatecall Error return value

function queryErc20BaseInfo(address a) public view returns(bool success, bytes memory list ) { (success , list) = address(a).staticcall(abi.encodeWithSignature("name()")); return (...
0 votes
2 answers
48 views

Wrong address rertun when I call ownerof with delegatecall

I am trying to call the function "ownerof" of a contract but it return me something like that : ...
0 votes
1 answer
482 views

Set data for call(), delegatecall(), etc, in Yul / inline assembly?

It seems that almost all the examples of external calls are simple proxies, which do something like this: assembly { // Copy msg.data. We take full control of memory in this inline ...
0 votes
1 answer
261 views

how to use the value of msg.value and msg.sender of a contract, when a function calls a different contract

I'm studing Solidity and tring to understand how it works. Starting from Safe Remote Purchase in the "Solidity section by example" the doc (https://docs.soliditylang.org/en/v0.8.12/solidity-...
  • 3
2 votes
1 answer
288 views

Chain of delegatecall and call

Situation is: A calling B delegate calling C calling D What would be the msg.sender in D? I performed some test in Remix and it looks like msg.sender in D is C's address. I don't get why it's not A's ...
  • 23
1 vote
0 answers
75 views

How to manually generate calldata

Here's my code snippet: function getCalldata(string calldata _func, string calldata _param1, uint256 _param2) public pure returns (bytes memory) { return abi.encodeWithSignature(_func, _param1,...
0 votes
0 answers
35 views

delegatecall, but with modifying the Caller contract state?

Example: EOA -> Caller Contract -> Target Contract As far as I can tell, delegatecall differs from normal calls in two very important ways: Call context is preserved, msg.value and msg.sender ...
0 votes
0 answers
73 views

How to debug smart contract delegatecall?

I am building an app that requires contact A to interact with a remote contract B. I am using solidity delegatecall function. After running it, I am seeing "Although one or more Error Occurred [...
0 votes
0 answers
69 views

How to instantiate functions of other smart contracts to write and read data from the same contract on Solidity?

I'm trying to understand inheritance, interfaces and the call of functions from other smart contracts in Solidity. So I did this example; there is a MyInterface interface in which is declare a struct ...
  • 1
1 vote
0 answers
153 views

Best practice for calling function from another contract

I'm a bit of a beginner so I'm sorry if I misphrase anything, but I haven't been able to find a definitive answer on this yet. I'm going through some tutorials which list out a few ways to call ...
  • 13
0 votes
0 answers
14 views

Exception disorder with or without nesting

I can’t understand following text: for a chain of nested calls (or delegatecalls) originated from a root call (or delegatecall), if the root call doesn’t throw exception while at least one of its ...
  • 1,285
0 votes
0 answers
33 views

delegatecall not setting the variable in the contract

I'm making a delegatecall like so: (bool success, bytes memory result) = target.delegatecall(msg.data); to initialize: function initialize( address creator, PartyInfo memory ...
0 votes
0 answers
126 views

delegatecall failing without a good reason

I'm calling a Proxy contract like so from contract A: (bool success, bytes memory result) = partyClone.call(abi.encodeWithSignature( "initialize(address,PartyInfo,address,...
0 votes
1 answer
246 views

TypeError: Member "initialize" not found or not visible after argument-dependent lookup in contract PartyRegistry

I'm calling a contract like so: PartyRegistry(partyClone).initialize( msg.sender, partyInfo, stableCoin, initialDeposit, PLATFORM_ADDRESS ...
1 vote
1 answer
261 views

delegatecall approve of an ERC20 contract

I try to call approve from a contract of another ERC20 contract: The delegate call: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Delegate { address public constant f24 = ...
  • 321
3 votes
1 answer
153 views

delegatecall in Brownie

I am trying to perform delegatecall in Brownie solving the Delegation task in the Ethernaut app in order to claim ownership of the Delegate contract (see below). What is the equivalent of the ...