Skip to main content
Fix logic flaw in code
Source Link
Foxxxey
  • 4.5k
  • 1
  • 7
  • 22

Delegatecall doesnt send any ETH or anything to the called contract. It just allows you to execute code from a contract in the context of another contract. Like so :

Contract Logic {
 uint a; 

 function updateA() external {
   a =1;
 }
}

Contract Proxy{
 address logic;
 uint a = 0;
 address logic;

 function delegate() {
  (bool s,) = logic.delegateCall(abi.encodeWithSignature("updateA()");
  require(s);
  //After that, Proxy's a will be 1, Logic's a will stay untouched 
 }
}

It's typically used for proxies (e.g: if you want to be able to update the logic later, or if you need to deploy multiple instances of the same contract and want to save on deployment costs by deploying the logic only once)

Delegatecall doesnt send any ETH or anything to the called contract. It just allows you to execute code from a contract in the context of another contract. Like so :

Contract Logic {
 uint a; 

 function updateA() external {
   a =1;
 }
}

Contract Proxy{
 address logic;
 uint a = 0;

 function delegate() {
  (bool s,) = logic.delegateCall(abi.encodeWithSignature("updateA()");
  require(s);
  //After that, Proxy's a will be 1, Logic's a will stay untouched 
 }
}

It's typically used for proxies (e.g: if you want to be able to update the logic later, or if you need to deploy multiple instances of the same contract and want to save on deployment costs by deploying the logic only once)

Delegatecall doesnt send any ETH or anything to the called contract. It just allows you to execute code from a contract in the context of another contract. Like so :

Contract Logic {
 uint a; 

 function updateA() external {
   a =1;
 }
}

Contract Proxy{
 uint a = 0;
 address logic;

 function delegate() {
  (bool s,) = logic.delegateCall(abi.encodeWithSignature("updateA()");
  require(s);
  //After that, Proxy's a will be 1, Logic's a will stay untouched 
 }
}

It's typically used for proxies (e.g: if you want to be able to update the logic later, or if you need to deploy multiple instances of the same contract and want to save on deployment costs by deploying the logic only once)

added 14 characters in body
Source Link
Rob Hitchens
  • 55.6k
  • 11
  • 91
  • 146

Delegatecall doesnt send any ETH or anything to the called contract. It just allows you to execute code from a contract in the context of another contract. Like so :

Contract Logic {
 uint a;  

 function updateA() external {
   a =1;
 }
} 

Contract Proxy{
 address logic;
 uint a = 0; 

 function delegate() {
  (bool s,) = logic.delegateCall(abi.encodeWithSignature("updateA()");
  require(s);
  //After that, Proxy's a will be 1, Logic's a will stay untouched 
 }
}

It's typically used for proxies (e.g: if you want to be able to update the logic later, or if you need to deploy multiple instances of the same contract and want to save on deployment costs by deploying the logic only once)

Delegatecall doesnt send any ETH or anything to the called contract. It just allows you to execute code from a contract in the context of another contract. Like so :

Contract Logic {
uint a; 
function updateA() external {
  a =1;
}
}
Contract Proxy{
address logic;
uint a = 0;
function delegate() {
  (bool s,) = logic.delegateCall(abi.encodeWithSignature("updateA()");
  require(s);
  //After that, Proxy's a will be 1, Logic's a will stay untouched 
}
}

It's typically used for proxies (e.g: if you want to be able to update the logic later, or if you need to deploy multiple instances of the same contract and want to save on deployment costs by deploying the logic only once)

Delegatecall doesnt send any ETH or anything to the called contract. It just allows you to execute code from a contract in the context of another contract. Like so :

Contract Logic {
 uint a;  

 function updateA() external {
   a =1;
 }
} 

Contract Proxy{
 address logic;
 uint a = 0; 

 function delegate() {
  (bool s,) = logic.delegateCall(abi.encodeWithSignature("updateA()");
  require(s);
  //After that, Proxy's a will be 1, Logic's a will stay untouched 
 }
}

It's typically used for proxies (e.g: if you want to be able to update the logic later, or if you need to deploy multiple instances of the same contract and want to save on deployment costs by deploying the logic only once)

Source Link
Foxxxey
  • 4.5k
  • 1
  • 7
  • 22

Delegatecall doesnt send any ETH or anything to the called contract. It just allows you to execute code from a contract in the context of another contract. Like so :

Contract Logic {
uint a; 
function updateA() external {
  a =1;
}
}
Contract Proxy{
address logic;
uint a = 0;
function delegate() {
  (bool s,) = logic.delegateCall(abi.encodeWithSignature("updateA()");
  require(s);
  //After that, Proxy's a will be 1, Logic's a will stay untouched 
}
}

It's typically used for proxies (e.g: if you want to be able to update the logic later, or if you need to deploy multiple instances of the same contract and want to save on deployment costs by deploying the logic only once)