Questions tagged [delegatecall]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
12 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
15 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
19 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
48 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
40 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
53 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
84 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
23 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
68 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
30 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
97 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
59 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
104 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
41 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
0answers
46 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
43 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
30 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
67 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
71 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
95 views

Using delegatecall for multiple parameters fuction in solidity

Does someone have a exemple of solidity delegatecall for multiple parameters function?
10
votes
2answers
507 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
51 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
302 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
30 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
44 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
157 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
107 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
164 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
48 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
138 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
52 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
73 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
73 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 ...
2
votes
1answer
311 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
76 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
70 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
143 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
158 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
39 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
375 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
170 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
167 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
158 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
446 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
2k 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
100 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
390 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
182 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
261 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 ...