Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pages/abi-encode/AbiEncode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract AbiEncode {
pure
returns (bytes memory)
{
// Typo is not checked - "transfer(address, uint)"
// Example with correct signature: "transfer(address,uint256)"
return abi.encodeWithSignature("transfer(address,uint256)", to, amount);
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/pages/abi-encode/index.html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const html = `<pre><code class="language-solidity"><span class="hljs-comment">//
<span class="hljs-title"><span class="hljs-keyword">pure</span></span>
<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>)
</span>{
<span class="hljs-comment">// Typo is not checked - "transfer(address, uint)"</span>
<span class="hljs-comment">// Correct function signature encoding; typos here are not caught at compile time</span>
<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);
}

Expand All @@ -52,7 +52,7 @@ const html = `<pre><code class="language-solidity"><span class="hljs-comment">//
<span class="hljs-title"><span class="hljs-keyword">pure</span></span>
<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>)
</span>{
<span class="hljs-comment">// Type is not checked - (IERC20.transfer.selector, true, amount)</span>
<span class="hljs-comment">// Selector is used; types are not checked at compile-time</span>
<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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/app/erc20/index.html.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// metadata
export const version = "0.8.26"
export const title = "ERC20"
export const title = "ERC20 Token Example and Swap in Solidity"
export const description = "Example of ERC20 token in Solidity"
export const cyfrinLink = "https://www.cyfrin.io/glossary/erc-20-solidity-code-example"

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

export const codes = [
{
Expand Down