Skip to content

Commit

Permalink
Merge pull request #492 from charliex2/main
Browse files Browse the repository at this point in the history
Update readme.md:uint 修改为uint8
  • Loading branch information
AmazingAng committed May 5, 2023
2 parents 82b0fe6 + 38f1d14 commit 2b37ac1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 27_ABIEncode/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tags:
编码的结果为`0x000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000007a58c0be72be218b41c608b7fe7c5bb630736c7100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000043078414100000000000000000000000000000000000000000000000000000000`,由于`abi.encode`将每个数据都填充为32字节,中间有很多`0`

### `abi.encodePacked`
将给定参数根据其所需最低空间编码。它类似 `abi.encode`,但是会把其中填充的很多`0`省略。比如,只用1字节来编码`uint`类型。当你想省空间,并且不与合约交互的时候,可以使用`abi.encodePacked`,例如算一些数据的`hash`时。
将给定参数根据其所需最低空间编码。它类似 `abi.encode`,但是会把其中填充的很多`0`省略。比如,只用1字节来编码`uint8`类型。当你想省空间,并且不与合约交互的时候,可以使用`abi.encodePacked`,例如算一些数据的`hash`时。

```solidity
function encodePacked() public view returns(bytes memory result) {
Expand Down

0 comments on commit 2b37ac1

Please sign in to comment.