2022 Developer Survey is open! Take survey.

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
0 votes
0 answers
6 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 ...
user avatar
  • 163
0 votes
0 answers
7 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.
user avatar
  • 1
0 votes
0 answers
15 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 `...
user avatar
  • 1
0 votes
0 answers
5 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 ...
user avatar
  • 265
0 votes
1 answer
33 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; ...
user avatar
  • 105
1 vote
1 answer
25 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 ...
user avatar
  • 265
1 vote
2 answers
59 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-...
user avatar
  • 11
0 votes
1 answer
9 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; ...
user avatar
  • 3
1 vote
1 answer
27 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?
user avatar
0 votes
2 answers
79 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....
user avatar
0 votes
1 answer
61 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....
user avatar
  • 3
0 votes
1 answer
22 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 ...
user avatar
  • 101
0 votes
1 answer
48 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 ...
user avatar
  • 265
0 votes
1 answer
17 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) } ...
user avatar
0 votes
1 answer
47 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 (...
user avatar
0 votes
2 answers
34 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 : ...
user avatar
0 votes
1 answer
124 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 ...
user avatar
0 votes
1 answer
41 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-...
user avatar
  • 3
2 votes
1 answer
99 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 ...
user avatar
  • 23
1 vote
0 answers
39 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,...
user avatar
0 votes
0 answers
16 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 ...
user avatar
0 votes
0 answers
43 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 [...
user avatar
0 votes
0 answers
35 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 ...
user avatar
  • 1
1 vote
0 answers
54 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 ...
user avatar
  • 13
0 votes
0 answers
9 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 ...
user avatar
  • 1,195
0 votes
0 answers
17 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 ...
user avatar
0 votes
0 answers
56 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,...
user avatar
0 votes
1 answer
142 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 ...
user avatar
1 vote
1 answer
75 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 = ...
user avatar
  • 189
2 votes
1 answer
79 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 ...
user avatar
0 votes
1 answer
93 views

How can I invoke the fallback method with sendTransaction?

I'm testing the delegatecall vulnerability. And I've created two contracts to do that. WalletLibrary.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyWalletLibrary { uint ...
user avatar
  • 147
0 votes
1 answer
62 views

State variable not updated after DelegateCall

I deployed two contracts 'WalletLibrary' and 'Wallet': most of the functions in Wallet delegateCall() the functions from WalletLibrary. I want to recreate an Attack, where I call the initWallet() ...
user avatar
0 votes
1 answer
487 views

Why is there significant gas costs associated with call and delegate call?

I've been trying to understanding why Ethereum doesn't have a significant on chain package/library ecosystem despite having the capacity to do so via delegatecall or call to an ImplementationContract ...
user avatar
  • 180
1 vote
0 answers
106 views

DelegateCall returning false

I'm learning Solidity and tried to create a couple of contracts on Truffle. For this, I have created a Shop.sol contract that can "Buy" items using an ERC20 token. Inside the buyItem() ...
user avatar
0 votes
2 answers
63 views

Reducing token transfers with a delegatecall

I am trying to solve a circular dependency in a "toy" app to test upgradable contracts. I have a Treasury contract containing ERC20 tokens and an upgradable set of Action contracts. The ...
user avatar
  • 113
0 votes
1 answer
120 views

Why does this result in an infinite loop?

I am doing this exercise: https://ethernaut.openzeppelin.com/level/0x9451961b7Aea1Df57bc20CC68D72f662241b5493 I expect my contract to call a non existent method in Delegation which then calls the ...
user avatar
0 votes
1 answer
61 views

Is it possible to delegatecall a function that calls a private function?

I don't think this is possible but I would just like to make sure. An example would be the following? pragma solidity ^0.4.0; // SPDX-License-Identifier: Unlicensed contract Victim{ ERC20 token; ...
user avatar
0 votes
1 answer
76 views

How to use a library contract function inside my contract without inheriting

I have a library contract deployed on ropsten with address 0xc0b843678E1E73c090De725Ee1Af6a9F728E2C47 and code // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; library ...
user avatar
0 votes
1 answer
48 views

Can I delegatecall my own internal function?

I have a contract that uses address(this).delegatecall(...) Can I put an internal function inside the delegatecall somehow? I tried the normal way, public functions worked but internal didn't. Is ...
user avatar
  • 391
0 votes
0 answers
62 views

Proxying a contract with delegatecall and matching storage layout

I am looking to add some additional functionality to an existing deployed smart contract. The function I would like to call on the target contract requires that the msg.sender be the wallet, so simply ...
user avatar
  • 101
4 votes
1 answer
85 views

Does `delegatecall` create a new stack frame?

It seems like it was introduced to replace callcode because callcode modified msg.sender and msg.value, and that breaks a lot of use cases. If the msg fields aren't changed, that leads us to think a ...
user avatar
0 votes
0 answers
46 views

delegatecall return wrong value

I want to get userInfo which is masterchef's methods. But I want to call userInfo from another contract, so I'm using delegatecall address sender = msg.sender; (bool success, bytes memory result) = ...
user avatar
0 votes
0 answers
56 views

What does "caller()" return in Yul when DELEGATECALL is used?

While browsing the Solidity docs, I noticed this instruction available in assembly: caller(): call sender (excluding delegatecall) What do the docs mean by "excluding delegatecall"? Is it ...
user avatar
0 votes
1 answer
192 views

Can I use delegatecall with the target contract's storage?

With a scenario that goes as follows: I want a Contract A that allows me to call functions from other contracts, different each time, using the storage and code of the target contract. Essentially, I ...
user avatar
0 votes
0 answers
38 views

Using delegatecall [duplicate]

I have a contract from which I want to do a delegatecall, which approvesForAll the contract A in contract B. I use delegatecall to keep the sender the one initiating the transaction. function ...
user avatar
  • 27
1 vote
0 answers
194 views

Does a proxy contract need to declare state variables?

There is no variable declaration in the proxy contract. Does the returned data from the delegate call auto-generate the variables for the proxy contract? contract Logic { uint256 varA; ...
user avatar
  • 11
0 votes
1 answer
368 views

How does Solidity decode a struct returned from a delegate call?

I have a proxy contract that delegate calls to a target contract. The proxy is similar to DSProxy. In it, there is an execute function: function execute(address target, bytes memory data) external ...
user avatar
1 vote
1 answer
48 views

How to alter the gas stipend with high-level delegate call?

When using the DELEGATECALL opcode via assembly, we can pass a specific amount of gas: let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) But the high-level DELEGATECALL does ...
user avatar
1 vote
1 answer
131 views

Understanding why this blob of assembly code adds 0x20 and 0x1f [duplicate]

The execute function defined in MakerDAO's DSProxy contains this blob of assembly code: assembly { let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 0) ...
user avatar
1 vote
0 answers
123 views

Why is delegatecall returning 0 and erroring?

I'm working with OpenZeppelin upgradable proxies, as well as their governance. I have a propose function that looks like: function propose( address[] memory targets, uint256[] memory ...
user avatar