Questions tagged [delegatecall]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
0answers
34 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
15 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
24 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
22 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 ...
1
vote
1answer
51 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'...
3
votes
1answer
53 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
32 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
28 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 ...
0
votes
0answers
18 views

Proxy delegation contract doesn't work

I'm trying to make a proxy to make a contract that I can change for an ethereum project. I did what it says here: https://hackernoon.com/how-to-make-smart-contracts-upgradable-2612e771d5a2 but it ...
2
votes
1answer
22 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
68 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
77 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
16 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
111 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)",...
1
vote
1answer
208 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
42 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
158 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
1answer
38 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
151 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
105 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
192 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
43 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
51 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
31 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
131 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
92 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
131 views

Using delegatecall for multiple parameters fuction in solidity

Does someone have a exemple of solidity delegatecall for multiple parameters function?
10
votes
2answers
638 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
65 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 ...
2
votes
1answer
440 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
36 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
46 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
203 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
115 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 ...
1
vote
0answers
208 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
52 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
176 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
53 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
79 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
80 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 ...
3
votes
1answer
422 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: ...
1
vote
0answers
82 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
81 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 ...
1
vote
2answers
154 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
182 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
42 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
486 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
209 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
212 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
161 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 ...