Skip to content

docs(27_ABIEncode): add abi.encodeCall tutorial and example - #912

Open
xuyua9 wants to merge 1 commit into
AmazingAng:mainfrom
xuyua9:docs/27-abi-encode-call
Open

docs(27_ABIEncode): add abi.encodeCall tutorial and example#912
xuyua9 wants to merge 1 commit into
AmazingAng:mainfrom
xuyua9:docs/27-abi-encode-call

Conversation

@xuyua9

@xuyua9 xuyua9 commented Jul 21, 2026

Copy link
Copy Markdown

What & Why

Closes #801.

abi.encodeCall is the compile-time-checked counterpart of abi.encodeWithSignature / abi.encodeWithSelector. Issue #801 asks for it to be added to the 27_ABIEncode chapter, and provides the canonical example.

This PR adds the fifth ABI encoding function to the chapter:

  • 27_ABIEncode/ABIEncode.sol: add a foo(uint256,address,string,uint256[2]) stub and an encodeCall() example that mirrors the existing encodeWithSignature / encodeWithSelector examples (same x, addr, name, array state).
  • 27_ABIEncode/readme.md: refresh the intro (4 -> 5 functions) and add a dedicated ### abi.encodeCall section that explains the compile-time signature/type check and that the calldata matches abi.encodeWithSignature("foo(uint256,address,string,uint256[2])", ...).
  • Languages/pt-br/27_ABIEncode/{ABIEncode.sol,readme.md}: mirror the same code and readme changes for the Portuguese localization, keeping the chapter in sync across translations.

The chapter structure and example style are unchanged; only the new section is appended between abi.encodeWithSelector and abi.decode.

Type of PR

  • Typo(勘误)
  • BUG(程序错误)
  • Improvement(提升)
  • Feature(新特性)

Refs

Closes AmazingAng#801.

Add a fifth ABI encoding function, abi.encodeCall, to the 27_ABIEncode
chapter. abi.encodeCall takes a function pointer and a tuple of arguments,
and performs compile-time checks on the function signature and parameter
types, making it safer than hand-written signatures used by
abi.encodeWithSignature / abi.encodeWithSelector.

- 27_ABIEncode/ABIEncode.sol: add foo() stub and encodeCall() example
- 27_ABIEncode/readme.md: refresh intro (4 -> 5 functions) and add a
  dedicated abi.encodeCall section
- Languages/pt-br/27_ABIEncode/{ABIEncode.sol,readme.md}: mirror the
  same changes for the Portuguese localization

The encoded calldata matches the existing
abi.encodeWithSignature("foo(uint256,address,string,uint256[2])", ...)
example used earlier in the chapter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][27.ABIEncode&Decode] Added abi.encodeCall

1 participant