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
1answer
12 views

pass storage through interface to library

Here is what am i doing: There is a library, accept storage argument as parameter, then do some math and return the result. And there is a contract to call the function in the library, and an extra ...
1
vote
1answer
42 views

Correct way to make a delegatecall? [duplicate]

I made a delegatecall to the REP contract to approve my contract to spend tokens on behalf of a user and my transaction is failing for some reason here is my code: (bool b,) = REPAddress.delegatecall(...
0
votes
1answer
9 views

Unstructured storage proxies. Variables not being overwritten?

When using delegate call I was under the impression that storage slots declared in the proxy will be overwritten by the implementation. Unstructured storage implementations declare bytes32 variables ...
1
vote
1answer
30 views

How to prevent the code of my contract being used in a CALLCODE?

Simple question but I couldn’t find the answer anywhere. How to know if the code of my contract is used in a CALLCODE or DELEGATECALL by third party sinceaddress(this)returns the address of the caller ...
0
votes
0answers
12 views

Delegatecall not changing state

I was trying the code in https://gist.github.com/sogoiii/f0ced0a4e569b5f38d302e7072d78b43 to observe the difference between call and delegatecall. pragma solidity ^0.4.18; contract D { uint public ...
0
votes
1answer
25 views

Difference in “delegate call via assembly”

I came across a different version of delegate call via assembly and also tried all of them - no different result so far. How does it differ and which is the best version to use? OpenZepplin version: ...
0
votes
0answers
28 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
22 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
19 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
59 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
39 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
25 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
82 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
53 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
32 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
77 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
168 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
481 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
76 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
160 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
111 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
131 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
86 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
65 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
382 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
312 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
163 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
99 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
84 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
88 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
570 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
79 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
23 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
74 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
309 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
168 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
307 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
138 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
337 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
232 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
574 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
502 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
258 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
224 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
80 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
157 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
301 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
287 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
109 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; ...