Questions tagged [delegatecall]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 views

Safe usage of delegatecall

Hey guys I have a few questions about delegatecall. The setup: I have 2 contracts A and B. A has 2 uint state variables B has 4 uint state variables To ensure storage layout compatibility, B ...
0
votes
1answer
16 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
16 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
25 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
29 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
28 views

Using delegatecall for multiple parameters fuction in solidity

Does someone have a exemple of solidity delegatecall for multiple parameters function?
8
votes
2answers
144 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
31 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 ...
1
vote
1answer
114 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 ...
0
votes
1answer
20 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
33 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 ...
1
vote
1answer
79 views

What's the equivalent of Vyper's create_forwarder_to in Solidity?

In Vyper, there's a built-in function called create_forwarder_to, which Duplicates a contract’s code and deploys it as a new instance, by means of a DELEGATECALL. If my understanding is correct, ...
1
vote
0answers
70 views

delegatecall (assembly) didn't change state variable in Remix with Web3 Provider

I am trying to test proxy pattern in Remix, which connected to my private chain with Web3 Provider. By the way, miner is working all the time. After invoking add function of Proxy contract, the state ...
0
votes
0answers
60 views

Anything like a static delegatecall from a view function?

let's say there are two contracts A and B, where A calls methods in B. I understand that A can modify and read storage in B with B.call() and B.staticcall(), ie. A can execute B's methods in the ...
0
votes
1answer
35 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
77 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
27 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
46 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
33 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
107 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
38 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
49 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
41 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
118 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 { ...
1
vote
0answers
78 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
27 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
197 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
100 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
110 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
139 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
315 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 ...
2
votes
1answer
1k 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
86 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 ...
2
votes
1answer
271 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
143 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
191 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
102 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 ...
3
votes
0answers
31 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
521 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
434 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
285 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
134 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
102 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
100 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
706 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
97 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
111 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
353 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
237 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
420 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 ...