Questions tagged [delegatecall]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 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
16 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
15 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
23 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
36 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
17 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
28 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
44 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
33 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
17 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
83 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
20 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
63 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
39 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
17 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
143 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
23 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
20 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 ...
2
votes
2answers
573 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
29 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
34 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
74 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
123 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
71 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
351 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
245 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
131 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
23 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
169 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
304 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
23 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
436 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
776 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
67 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
713 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
211 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
436 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
317 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
508 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
51 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
83 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
56 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
464 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
161 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
248 views

Using delegatecall for multiple parameters fuction in solidity

Does someone have a exemple of solidity delegatecall for multiple parameters function?
11
votes
2answers
1k views

Pros and Cons of smart contract upgradable patterns

There have been quite many arguments around how to achieve smart contract updates like Upgradeable smart contracts. I feel Proxycontract with Delegate-call is currently the most famous one. But aside ...
0
votes
0answers
128 views

No Events After Deploying Another Contract in Remix

I am trying to write an upgradable smart contract in Remix. This involves a Proxy contract, a Logic_0_1_0 contract, and a Logic_0_2_0 contract. I uploaded Proxy and Logic_0_1_0 only, and the ...
3
votes
1answer
1k views

Delegatecall return values solidity 5.0

With solidity 5.0+ , the delegatecall function can return a boolean and a bytes representing return value. I want to understand how does one convert the returned bytes to various datatypes. ex If ...
1
vote
1answer
40 views

Calling Msg.sender Natively

Caller -> Contract B -> Contract A Contract A has a msg.sender variable. I want to use the Caller as Msg.Sender for Contract A through Contract B. How is this done?
0
votes
1answer
62 views

How do you pause a Proxy-Logic pattern?

Suppose we have a Proxy contract that forwards to call to a Logic contract by using delegatecall. If we pause the Proxy, users will still be able to directly interact with the Logic contract. While ...