Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
seasidejuvenile666 authored Sep 2, 2022
1 parent b6a2333 commit a7a3113
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 46_ProxyContract/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ contract Logic {
- 构造函数:在部署合约时初始化`proxy`变量。
- `increase()`:利用`call`来调用代理合约的`increment()`函数,并返回一个`uint`。在调用时,我们利用`abi.encodeWithSignature()`获取了`increment()`函数的`selector`。在返回时,利用`abi.decode()`将返回值解码为`uint`类型。

```
```solidity
/**
* @dev Caller合约,调用代理合约,并获取执行结果
*/
Expand Down Expand Up @@ -184,4 +184,4 @@ contract Caller{

这一讲,我们介绍了代理模式和简单的代理合约。代理合约利用`delegatecall`将函数调用委托给了另一个逻辑合约,使得数据和逻辑分别由不同合约负责。并且,它利用内联汇编黑魔法,让没有返回值的回调函数也可以返回数据。下一讲,我们会介绍可升级代理合约。

代理合约虽然很强大,但是它非常容易出`bug`,用的时候最好直接复制[OpenZepplin](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/proxy)的模版合约。
代理合约虽然很强大,但是它非常容易出`bug`,用的时候最好直接复制[OpenZepplin](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/proxy)的模版合约。

0 comments on commit a7a3113

Please sign in to comment.