Stack Exchange Network

Stack Exchange network consists of 175 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
22 views

Is it possible to implement upgradable contract with new functions?

I have follows this answer related to Upgradeable smart contracts and Zeppelin's solution. I have tested those examples, where I was able to update the interface of the functions that are already ...
0
votes
0answers
8 views

Subtraces of delegatecall in Parity trace

I'm investigating transactions using Parity trace which provides useful data over a transaction flow. Among this data is the Subtraces field which allows me to understand how many sub-calls each ...
0
votes
1answer
9 views

DelegateCall to internal function doesn't store variable

Why isn't delegate call able to run internal functions? What is the difference between a self directed delegate call and a contract normally calling one of it's internal function? contract ...
0
votes
2answers
37 views

Code Example from “Mastering Ethereum: Building Smart Contracts and DApps” doesn't work

I'm reading the Ethereum book of Gavin Wood right know and the following code example gives an error message when I try to compile it with truffle: pragma solidity ^0.4.22; contract calledContract { ...
0
votes
0answers
26 views

Proxy contract DELEGATECALL to pass a DYNAMIC array to a function in the target contract

I'm trying to get a Proxy contract to correctly do a delegatecall to a function in another 'target' contract. The problem is, that I need to pass a dynamic array as the parameter to this function. Q: ...
1
vote
0answers
23 views

Replaying the Bad Parity Hack

On a locally hosted instance of Ethererum I am trying to replay and understand the Bad Parity hack. I have a Wallet and a Wallet Library Contract. Wallet.sol constructor(address lib) public payable {...
0
votes
1answer
38 views

Is it possible to send Ether using delegatecall?

I tested this in Remix and it seems that the ether remains in the delegator contract and doesn't get forwarded. Using the code below to test: contract SomeContract { address public sender; ...
1
vote
0answers
37 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
26 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
45 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
1answer
96 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
210 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
66 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
135 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 ...
0
votes
1answer
80 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 ...
1
vote
1answer
114 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
76 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
52 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)...
3
votes
0answers
28 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
330 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
2answers
278 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
116 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
84 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
80 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
86 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
488 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
76 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
22 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
65 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
284 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
150 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
281 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
126 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
1answer
311 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 ...
2
votes
1answer
207 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
554 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
1answer
488 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
244 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
217 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
78 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
154 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
285 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
280 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
102 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
204 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
332 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
132 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
498 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
627 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 ...
2
votes
0answers
550 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 ...