Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [delegatecall]

The tag has no usage guidance.

0
votes
0answers
2 views

How would you use a proxy erc20 contract if you cannot preserve msg.sender?

Let's say I use a proxy contract which allows me to make an ERC20 token transfer from my account. At the moment the only way to do so is to use tx.origin which gets the original EOA address of the ...
0
votes
1answer
21 views

Delegatecall: Storing values

Using a delegatecall() to call another contract will have that contract run from within your context (e.g. if it calls a contract on its turn as a result, msg.sender will be your address). I am aware ...
0
votes
0answers
13 views

How to allow delegatecall only from specific contract?

I have a token contract, when transfer is called it calls other contract's transfer with data. Other contract checks msg.sender and allows only the first contract to pass and performs some important ...
0
votes
0answers
20 views

How to use Role-Based Access Control via Proxy?

I have a PermissionsManager contract that uses OpenZeppelin's Role-Based Access Control (RBAC) template as a base. Currently function modifiers in my app call PermissionsManager directly to check for ...
1
vote
1answer
58 views

How does delegatecall work from Solidity 0.5.0 onwards?

I am trying, for learning purposes only, to make a mutable smart contract, but I couldn't find anything useful on stackexchange because everything I found was using pragma solidity ^0.4.x; So, I have ...
1
vote
0answers
42 views

Can anyone give me a working DELEGATECALL example? [duplicate]

I tried many variants of DELEGATECALL, but not one of them gave me the desired result. When used in assembly: = delegatecall (), I also don't get the result. I also used different versions of Solidity ...
0
votes
1answer
63 views

Calling fallback function in truffle to delegate a call

I'm playing with the upgradeable contracts via DelegateProxy in Solidity. This pattern posits that a MutableForwarder contract is deployed once, and all the subsequent calls to the upgradeable ...
-1
votes
0answers
23 views

Passing a string with delegatecall not working

I am working with proxy contracts so I have a storage contract that wants to delegate its logic over to a logic contract. I have the following delegatecall below which attempts to call writeData on ...
0
votes
1answer
35 views

Proxy Contract Not Updating Store Data

I want to setup a proxy contract that my users can interact with. The proxy contract is a store contract with stores the user's age for now. When I call writeData to update my age, I expect it to call ...
0
votes
1answer
66 views

contract kill function

as per ethereum docs Even if a contract’s code does not contain a call to selfdestruct, it can still perform that operation using delegatecall or callcode. is this real? 1.if it is then even if ...
2
votes
1answer
57 views

How does a contract know which library to query or know the library address?

How does a contract know which library to query? For Example in the code below (The code is from solidity docs: https://solidity.readthedocs.io/en/v0.4.24/contracts.html?highlight=library#libraries ...
1
vote
0answers
39 views

How to use delegate call with external Library contract?

Here is my Library Contract deployed at 0xdeadbeef: library UsefulLib { function caculateAddress(address origin, uint nonce) pure external returns (address) { if(nonce == 0x00)...
2
votes
0answers
23 views

Delegatecall Scope - Correct me if I'm wrong

When any contract function is called - delegatecall or otherwise - the EVM loads the requisite pointers & values into that call frame's volatile stack/memory. Example: Let's say we have contract ...
2
votes
3answers
225 views

Scope confusion using delegate call

I am having trouble understanding the scope with delegatecall method. Here are my two contracts: contract Caller { uint public testVar = 88; uint public myVariable = 6; function ...
2
votes
1answer
242 views

Double delegate call doesn't work

To create an upgradeable contract I have to use multiple proxies. The contract applies to Proxy A, then Proxy A applies to Proxy B. But delegatecall doesn't work in this case. The simplified code of ...
1
vote
1answer
73 views

Use of delegatecall with msg.data

I'm trying to understand below code: pragma solidity ^0.4.23; contract Relay { address public currentVersion; address public owner; modifier onlyOwner() { require(msg.sender == ...
0
votes
1answer
59 views

Delegatecall require statement does not cause an abortion in any way

This is a sequel to a previous question of mine. I want to implement a validation function (e.g. for passwords) within a central contract, that could be used by other contracts. It is important to ...
0
votes
1answer
70 views

What method can I use instead of delegatecall?

I see the warning security/no-low-level-calls: Avoid using low-level function 'delegatecall' when I use delegatecall function in my code. I understand why it's not a good way, but I still need that ...
1
vote
0answers
79 views

delegatecall for Smart Contract versioning

I've a state variable address public current; which stores the address of the latest updated contract. This value can be modified with a function. Then, I've a function of this kind function ...
1
vote
1answer
310 views

Solidity - selfdestruct

I'm just wondering what would happen if I don't put a selfdestrut() method in my smart contract. As I read from the Solidity documentation (Self-destruct): Even if a contract’s code does not ...
0
votes
1answer
66 views

When using Delegatecall or callcode, which Ether balance is used?

Simple question, but I couldn’t find the answer. When contract A CALLCODE B, B will uses A’s ledger. But which Ether balance will be used if B makes a normal transfer, the balance of A or the balance ...
0
votes
1answer
21 views

When a delgatecalled Callcalled contract calls an other contract normally, who is msg.sender?

If I understand correctly both DELEGATECALL and CALLCODE substitute/replace (and not add) the ledger of the target contract with the one the calling contract, isn’t it ? So that when contract Victor ...
0
votes
1answer
55 views

What’s the purpose of the delegatecall second target parameter?

Simple question, but I couldn’t figure the answer. Are there plans/EIP to use the second parameter of DELEGATECALL ? Or am I wrong (in which case the parameter isn’t ignored) ? In c++ Ethereum evm ...
3
votes
2answers
260 views

Solidity CALL and DELEGATECALL: messages and data format

I have some questions about Solidity CALL and DELEGATECALL. I have already read some related threads (link), but found no answers to my doubts. 1) Is there any difference in performing a CALL to a ...
0
votes
1answer
120 views

Upradeable proxy library throws on any function, how to connect proxy and maincontract

I'm trying to implement a proxy library through the techniques researched by openZeppelin using proxies. I have 4 contracts 1. Library with logic 2. Library containing the interface for the logic ...
5
votes
1answer
244 views

ERC20 Token tansfer through delegatecall throws

I'm trying to call the transfer() function on an ERC20 token through the use of delegatecall, my proxy contract however returns false from delegatecall. When I try to call view functions like ...
2
votes
0answers
105 views

delegatecall on library always run out of gas

I'm trying to replicate the Dynamic Library attack of this paper under a recent version of solidity and the EVM. Streamlining down the code, I've created this very simple contract (which is, in ...
0
votes
0answers
204 views

Delegate call through msg.data

In my SmartContracts course we are presented with challenges, this is an abstraction of the current challenge. From an attacker contract we are supposed to change the owner address (ownerInt) in the ...
0
votes
1answer
251 views

deletegateCall to change contract's ownership

I am currently going deep into some Solidity functionalities and I would like to be able to change a contract's A ownership from a contract B, knowing that the caller of contract B is the owner of ...
0
votes
1answer
166 views

Any way to have delegatecall change the delegate contract's storage state?

A delegatecall'ed function executes inside of the delegatecaller contract's own memory & storage context. But I'm wondering whether the following is in any way possible (i.e. if certain access ...
1
vote
1answer
523 views

Contract call from a contract from a contract?

As I understand it, it is possible for a contract to call another contract by using othercontractaddress.call(gas_amount).value(eth amount)(tx data). Or in this case sender -> contract A -> ...
0
votes
0answers
144 views

Delegatecall trouble

I'm trying to build a simple example using proxy contract and delegatecall but I'm having trouble making it work . What I'm trying to achieve is : Having a contract Dummy extending Proxy that will ...
0
votes
1answer
460 views

Delegatecall to an internal function

Let's say I have a Dispatcher contract that delegates all function calls to an Implementation contract using delegatecall (see for example https://gist.github.com/Arachnid/...
2
votes
1answer
223 views

Overriding Solidity selfdestruct

I create a contract and implement a cleanup function like this modifier ownerOnly { if(msg.sender != owner) revert(); _; } function cleanup() public ownerOnly { if(!canDelete()) { //...
0
votes
1answer
208 views

Contracts work on testrpc but not Rinkeby. Using delegatecall (upgradeable contracts) pattern and trying to add new Contract() to array is failing

I have a series of contracts that work perfectly fine on testrpc but not when I deploy to Rinkeby. I am using a standard token contract with Zeppelin that I am having no issues with. The issue is ...
2
votes
0answers
68 views

What's the value of `this` inside a library function when called via a delegatecall?

Imagine a contract C that makes a delegatecall to a library L. C -> L What's the value of this inside L: address(C) or address(L) ? If now that L makes a normal call to another contract D. C ->...
1
vote
0answers
143 views

What happens when contract is making delegatecall to deleted contract?

I read the whole Suicide Parity Multi-sig hack. One thing I don't understand is what happens when you call delegate call on deleted contract? I thought that contract should throw an exception but due ...
0
votes
1answer
269 views

Safety of Using DELEGATECALL with Mappings

To make my contract upgradable, I have a proxy contract that stores all of my data. As I understand it, when using delegatecall the storage layout needs to match for both the caller and callee. Due ...
1
vote
1answer
252 views

Abstract delegate call

So there is a way to call other contract using abstract prototype of that contract. But what about delegate calls? I need to split my huge contract into separate pieces. So i can call my functions ...
0
votes
1answer
85 views

delegateContract address getting reset on delegatecall using geth console

I've deployed the following contracts on the rinkeby testnet. They are completely separate with different addresses: pragma solidity ^0.4.11; contract Backend { address public delegateContract; ...
0
votes
1answer
176 views

General question: Reasons to use sha3 (or any hash) in contracts?

I'm going through the Numerai contracts and noticing a common pattern - https://github.com/numerai/contract/blob/master/contracts/NumeraireBackend.sol and https://gist.github.com/Arachnid/...
1
vote
0answers
300 views

delegatecall executes but does not change state

I am trying to make use of delegatecall function in solidity. function delegateTokens(uint256 _value) returns (bool result) { tokens[msg.sender] = _value; return token.delegatecall(bytes4(...
3
votes
2answers
131 views

Is it possible to get both address of the user and the contract when delegate call is used?

When the user calls the delegatecallSetN function of contract D below, the msg.sender in contract E is the address of the user (as shown in this example). contract D { uint public n; address ...
1
vote
1answer
444 views

When using delegatecall, data in parameters of type uint[] are left-shifted by 8 bits

progma solidity ^0.4.15; contract Callee { uint public result_; function foo (uint _length, uint[] _nums) public returns (uint) { result_ = 0; for ( uint i = 0; i <...
0
votes
1answer
546 views

Warning: The use of low level “call” should be avoided whenever possible

I am writing my own smart contract and I want to call a function from a contract that has already been deployed. The fragment of my code: function myFunc(address _contractAddress, address _user, uint ...
1
vote
0answers
526 views

Using delegatecall to forward eth

The following code snippet is designed to forward all funds to a single destination, but where multiple contract D's will exist, allowing differentiation of the original source of the funds. pragma ...
1
vote
0answers
141 views

out of gas error by assembly delegatecall

I want to get a return value from current contract call other contract by delegatecall, but got a error of out-of-gas. I try to add gas limit to 3000000000, but it doesn't work. please help me. And i ...
3
votes
1answer
439 views

Why does DELEGATECALL use 94k gas in my contract in Remix?

I was inspired by another question to learn more about stack depth attacks. When I try to run attack(1023) in Remix on this contract: pragma solidity ^0.4.14; contract Attacker { uint x; ...
2
votes
2answers
752 views

Is it possible to copy the internal storage of a smart contract to a new contract?

Assume that I want to implement my own version of a suicide contract function with extended functionality. More specifically, I want to copy the internal storage state of the contract to a new ...
3
votes
2answers
642 views

How to make function call through relay / entry level contract

I am trying to create an entry level contract (one that is the entry point): Relay.sol pragma solidity ^0.4.8; contract Relay { address public currentVersion; address public owner; ...