Questions tagged [delegatecall]

The tag has no usage guidance.

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

How to implement gasless transfers of ERC777 tokens?

I'm trying to make a contract (erc777TransferPayer) that pays for user transactions of any ERC777 token. For example, in this erc777TransferPayer contract, a user could call something like: freeSend(...
0
votes
1answer
39 views

Struct on delegatecall

Is it possible to pass a struct as an argument to delegatecall ? I have this function that calls delegatecall and takes a struct (a 0x quote) as an argument which is later used on the function ...
0
votes
0answers
15 views

Encoded delegate calls fails

I have been using encodeFunctionCall() utils for encoding my function call. when i use the encoded data to execute delegateCall(), it gets reverted. My solidity call is like bool success, ) = ...
0
votes
1answer
41 views

Delegatecall correct syntax is needed

There two contracts A and B. Both them have too simple code and it's because of a test, and B deployed before A deployment. B has a function called modify. A has a function called caller that takes a ...
1
vote
1answer
27 views

delegatecall call internal functions from caller contract

Is it possible to call internal functions from a function called using delegatecall? Contract A call contract B using delegatecall, contract B needs to call an internal function from contract A.
0
votes
1answer
14 views

Calling a function[A] that in turn calls a function[B] from another Contract

I have two Contracts, Domain and Serial deployed separately. NOTE: Most of the code is ommited for simplicity. contract Serial { Domain DOMAIN; //Domain contract is imported and set by ...
2
votes
1answer
56 views

Call fallback function from eth-brownie from proxy

I have a contract that has a fallback function to delegatecall all function calls to a different contract. I can't seem to use my typical API to interact with the contract it delegates a call to. I ...
0
votes
0answers
20 views

How does DELEGATECALL behave when calling other contracts?

I am trying to make a Parent-Contract which has a function which spends ERC-20 Tokens. I want to call this function from different Child-Contracts (which are deployed independently) using Delegatecall....
0
votes
0answers
14 views

Delegate Call fails

I have the following function enum OptionType {Invalid, Put, Call} function create( uint256 period, uint256 amount, uint256 strike, OptionType optionType ) { .... } When I ...
2
votes
2answers
275 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
28 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
33 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
61 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
67 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'...
4
votes
1answer
243 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
162 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
89 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
30 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
23 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
132 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
230 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
23 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
313 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)",...
2
votes
1answer
592 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
60 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
529 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
130 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
330 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
269 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 ...
0
votes
1answer
398 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
47 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
77 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
51 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
360 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
131 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
213 views

Using delegatecall for multiple parameters fuction in solidity

Does someone have a exemple of solidity delegatecall for multiple parameters function?
11
votes
2answers
1k 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
106 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
800 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 ...
1
vote
1answer
39 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
56 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
315 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
154 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 ...
2
votes
0answers
305 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
104 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 ...
2
votes
1answer
269 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
63 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
131 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
128 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
671 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: ...