Skip to content

Commit 059897c

Browse files
authored
Merge pull request #329 from Pronoss/fix/update
Improve ABI encoding comments and refactor ERC20 Metadata
2 parents b362650 + 82b830c commit 059897c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/pages/abi-encode/AbiEncode.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ contract AbiEncode {
2020
pure
2121
returns (bytes memory)
2222
{
23-
// Typo is not checked - "transfer(address, uint)"
23+
// Example with correct signature: "transfer(address,uint256)"
2424
return abi.encodeWithSignature("transfer(address,uint256)", to, amount);
2525
}
2626

@@ -29,7 +29,7 @@ contract AbiEncode {
2929
pure
3030
returns (bytes memory)
3131
{
32-
// Type is not checked - (IERC20.transfer.selector, true, amount)
32+
// Types are not checked at compile-time
3333
return abi.encodeWithSelector(IERC20.transfer.selector, to, amount);
3434
}
3535

src/pages/abi-encode/index.html.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const html = `<pre><code class="language-solidity"><span class="hljs-comment">//
4343
<span class="hljs-title"><span class="hljs-keyword">pure</span></span>
4444
<span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bytes</span> <span class="hljs-keyword">memory</span></span>)
4545
</span>{
46-
<span class="hljs-comment">// Typo is not checked - "transfer(address, uint)"</span>
46+
<span class="hljs-comment">// Correct function signature encoding; typos here are not caught at compile time</span>
4747
<span class="hljs-keyword">return</span> <span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encodeWithSignature</span>(<span class="hljs-string">"transfer(address,uint256)"</span>, to, amount);
4848
}
4949
@@ -52,7 +52,7 @@ const html = `<pre><code class="language-solidity"><span class="hljs-comment">//
5252
<span class="hljs-title"><span class="hljs-keyword">pure</span></span>
5353
<span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bytes</span> <span class="hljs-keyword">memory</span></span>)
5454
</span>{
55-
<span class="hljs-comment">// Type is not checked - (IERC20.transfer.selector, true, amount)</span>
55+
<span class="hljs-comment">// Selector is used; types are not checked at compile-time</span>
5656
<span class="hljs-keyword">return</span> <span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encodeWithSelector</span>(IERC20.<span class="hljs-built_in">transfer</span>.<span class="hljs-built_in">selector</span>, to, amount);
5757
}
5858

src/pages/app/erc20/index.html.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// metadata
22
export const version = "0.8.26"
3-
export const title = "ERC20"
3+
export const title = "ERC20 Token Example and Swap in Solidity"
44
export const description = "Example of ERC20 token in Solidity"
55
export const cyfrinLink = "https://www.cyfrin.io/glossary/erc-20-solidity-code-example"
66

7-
export const keywords = ["app", "application", "erc20", "ierc20", "token"]
7+
export const keywords = ["erc20", "solidity", "smart contract", "mint", "burn", "token swap", "ierc20", "token", "dapp"]
88

99
export const codes = [
1010
{

0 commit comments

Comments
 (0)