Questions tagged [delegatecall]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 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 ...
0
votes
1answer
16 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 ...
0
votes
0answers
9 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 ...
4
votes
1answer
73 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 ...
0
votes
0answers
20 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) = ...
0
votes
0answers
14 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 ...
0
votes
1answer
33 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 ...
0
votes
0answers
18 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 ...
1
vote
0answers
38 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; ...
0
votes
1answer
75 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 ...
1
vote
1answer
18 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 ...
1
vote
1answer
32 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) ...
1
vote
0answers
55 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 ...
0
votes
1answer
63 views

Delegate Call Reverting for Unknown Reason

I'm trying to make a delegatecall to the PancakeSwap Routerv2 from my contract, to perform a swap, but for some reason it's not working. Here's my code: // pancakeswap router address address public ...
0
votes
0answers
20 views

How to implement gasless transfers of ERC777 tokens?

I'm trying to make a contract (erc777TransferPayer) that pays for user transactions of any ERC777 token. For example, in this erc777TransferPayer contract, a user could call something like: freeSend(...
0
votes
1answer
103 views

Struct on delegatecall

Is it possible to pass a struct as an argument to delegatecall ? I have this function that calls delegatecall and takes a struct (a 0x quote) as an argument which is later used on the function ...
0
votes
0answers
22 views

Encoded delegate calls fails

I have been using encodeFunctionCall() utils for encoding my function call. when i use the encoded data to execute delegateCall(), it gets reverted. My solidity call is like bool success, ) = ...
0
votes
1answer
83 views

Delegatecall correct syntax is needed

There two contracts A and B. Both them have too simple code and it's because of a test, and B deployed before A deployment. B has a function called modify. A has a function called caller that takes a ...
2
votes
1answer
43 views

delegatecall call internal functions from caller contract

Is it possible to call internal functions from a function called using delegatecall? Contract A call contract B using delegatecall, contract B needs to call an internal function from contract A.
0
votes
1answer
20 views

Calling a function[A] that in turn calls a function[B] from another Contract

I have two Contracts, Domain and Serial deployed separately. NOTE: Most of the code is ommited for simplicity. contract Serial { Domain DOMAIN; //Domain contract is imported and set by ...
2
votes
1answer
176 views

Call fallback function from eth-brownie from proxy

I have a contract that has a fallback function to delegatecall all function calls to a different contract. I can't seem to use my typical API to interact with the contract it delegates a call to. I ...
0
votes
0answers
35 views

How does DELEGATECALL behave when calling other contracts?

I am trying to make a Parent-Contract which has a function which spends ERC-20 Tokens. I want to call this function from different Child-Contracts (which are deployed independently) using Delegatecall....
0
votes
0answers
22 views

Delegate Call fails

I have the following function enum OptionType {Invalid, Put, Call} function create( uint256 period, uint256 amount, uint256 strike, OptionType optionType ) { .... } When I ...
3
votes
2answers
736 views

What is the difference between the STATICCALL and CALL EVM opcodes?

Besides the regular and very common CALL, the Ethereum Virtual Machine has the STATICCALL opcode. In which ways does it differ from the regular CALL? Edit: This is not a duplicate because this ...
0
votes
1answer
30 views

Cannot get very simple delegatecall to work

I have this super simple code: pragma solidity 0.5.13; contract test1{ uint256 public number; address public sender; function setNumber(uint256 _number) public { number =...
0
votes
0answers
36 views

Does delegatecall() use only the calling function?

Let me explain with the code: contract A { function f() public { [...] g(); } function g() private { [...] } } contract B { A a; function delegateA() public { (bool success, ) = address(...
0
votes
0answers
80 views

Are libraries part of the storage of a smart contract?

I want to create a proxy contract and another contract which refers to its functions using delegatecall(). Here's a snippet of the proxy: pragma solidity ^0.5.0; /** * @dev Standard math ...
0
votes
1answer
130 views

Why does this call to DSProxy fail?

Take these two contracts, both deployed on Kovan and with the source code verified: DSProxy: 0xa92Bed719071A4d33B0B348513E7e866a6ff6B3F TargetContract: 0xE3CD2e7a628b57d3e50c5f7B921182f676721bDF And ...
1
vote
1answer
76 views

Preserve msg.sender but not storage

In this particular scheme, we pass the address of the Attacker contract in Victim.foo. By using delegatecall, we maintain the msg.sender field, but we are not using the storage of Storage but Attacker'...
5
votes
1answer
396 views

What is the value of "address(this)" when delegate calling?

Suppose that you have an upgradeable proxy "Foo" that calls an implementation contract "Bar" via DELEGATECALL. In "Bar", there is a function that uses the Solidity syntax ...
0
votes
1answer
279 views

strange revert on proxy pattern delegate call [closed]

I've worked with upgradeable contracts before using zeppelin's upgradeable contract pattern. However, I found out that if I try to fetch the implementation contract address through a contract call, I ...
0
votes
1answer
151 views

How to get the returned value from the delegate call on the function of another contract?

Here is my example: contract A { function a() public returns(uint256) { return 1; } } contract B { address addrOfA; function b() public returns(uint256) { (, bytes ...
2
votes
1answer
24 views

Am I locked to one solc version for upgradeable smart contracts?

I want to use delegatecall to make my contracts upgradeable. Is it true that variable layout may break if I change the solc version and therefore I should use the same Solidity version for all future ...
1
vote
0answers
184 views

How to call the super contract function where msg.sender should be same in solidity?

I am trying to call contract A.fun_A() via Contract C contract A{ function fun_A(address tenant, uint itemId){ //Here the msg.sender should be msg.sender in C require(msg.sender == ...
1
vote
1answer
357 views

How to make a delegatecall to external ERC20 token's approve function?

What I would like to do is something like this: function testCall(uint amount) public virtual returns (bool) { address tta = address(0xE7B6....); (bool success, bytes memory result) = tta....
1
vote
0answers
25 views

How to transfer a contract address to ContractRef type(ContractRef is a reference to the contract's backing object) in Go-ethereum

I want to call DelegateCall(caller ContractRef, addr common.Address, input []byte, gas uint64) in geth, but it can only be triggered by the opcode. So I want to convert address of deployed contract ...
1
vote
2answers
504 views

In assembly... can't get delegatecall to work

Delegatecall can be used in either solidity or assembly. In solidity, I can get it working with the following code: bytes memory payload = abi.encodeWithSignature ("get_value(uint16,uint16)",...
2
votes
1answer
881 views

Transfer ERC20 via onother smart contract (call transfer as delegate)

I want to deposit erc20 tokens to a smart contract. But when I just send it to he address, I can't handle the deposit. So I tried to use the delegatecall function to do the transfer. Basically I ...
0
votes
1answer
75 views

Call few contract methods from another contract consistently

Can I call a few contract methods from another contract consistently in one block? The order of methods calls is important! if (contract.method1.value(msg.value)()) { contract.method2(someValue); }
1
vote
1answer
815 views

Usecase for approve and allowance functions of ERC20 token

Could you please enlighten me on how approve and allowance functions work using a usecase? I dont understand the underlying operations of these functions. Especially, when a token owner delegates the ...
0
votes
2answers
271 views

How do you call a fallback function that uses msg.data for parameters

I am trying to complete a homework assignment, so I am not doing something malicious. The goal is to learn the vulnerabilities of contracts. I want to call the fallback function of wallet to trigger ...
2
votes
1answer
493 views

How to perform delegate call inside of view call (staticall)?

Inside view method it's not possible to do delegatecall due to compilation errors. Is there any way to delegate view calls?
1
vote
1answer
350 views

Dynamic Delegate Proxy contract

I'm familiar with proxy contracts in solidity using the 'delegatecall' to separate out the proxy contract from the logic contract. Is there a simple way to choose the logic contract based on an ...
1
vote
1answer
587 views

Factory contract to clone existing contracts

I am researching about Factory contract to clone existing contracts, First is the implementation present at https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol. I don't ...
1
vote
0answers
52 views

What are "if" and "this" in this function?

function() public { if(delegate.delegatecall(msg.data)) { this; What are the requirements for "if" to execute "this" and what does "this" refer to in this function?
0
votes
1answer
90 views

Upgradable contract proxy pattern: Get the invoked method name in the fallback function

I have a proxy smart contract and I would like to get the name of the called method in the fallback function. Is there a way? For example, if I call the function getName() (stored in the logic ...
1
vote
0answers
60 views

How dangerous is this: number of contracts contain a function like "approveandcall" which lets anyone call any contract (some thoughts?)

The most common implementation is as follows: function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(...
1
vote
1answer
501 views

How to use call, delegate call?

I have created two contracts A and B as follow: Contract A: pragma solidity 0.4.25; contract A{ // uint public X ; event MyName(address _from, address sender); function checkMe(uint val)...
0
votes
0answers
168 views

How to use delegate call with or without arguments functions?

Below is my contract: contract A{ mapping (address => uint) public balances; function put() payable public { balances[msg.sender] = msg.value; } function get(address ...
0
votes
1answer
267 views

Using delegatecall for multiple parameters fuction in solidity

Does someone have a exemple of solidity delegatecall for multiple parameters function?