<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[U2security]]></title><description><![CDATA[U2security]]></description><link>https://blog.u2sec.io</link><image><url>https://substackcdn.com/image/fetch/$s_!3HK4!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe21c4d90-9823-46a2-b3b3-68979ac070bc_667x667.png</url><title>U2security</title><link>https://blog.u2sec.io</link></image><generator>Substack</generator><lastBuildDate>Thu, 04 Jun 2026 00:23:06 GMT</lastBuildDate><atom:link href="https://blog.u2sec.io/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Lakatos]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[u2security@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[u2security@substack.com]]></itunes:email><itunes:name><![CDATA[U2SEC]]></itunes:name></itunes:owner><itunes:author><![CDATA[U2SEC]]></itunes:author><googleplay:owner><![CDATA[u2security@substack.com]]></googleplay:owner><googleplay:email><![CDATA[u2security@substack.com]]></googleplay:email><googleplay:author><![CDATA[U2SEC]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Foundry 101]]></title><description><![CDATA[Khi m&#7899;i t&#236;m hi&#7875;u v&#7873; web3 m&#236;nh th&#7845;y c&#361;ng c&#243; kh&#225; nhi&#7873;u c&#244;ng c&#7909; gi&#250;p ch&#250;ng ta ph&#225;t tri&#7875;n SC (smartcontract) nh&#432; Truffle, HardHat, Foundry.]]></description><link>https://blog.u2sec.io/p/foundry-101</link><guid isPermaLink="false">https://blog.u2sec.io/p/foundry-101</guid><dc:creator><![CDATA[u2sec]]></dc:creator><pubDate>Sun, 12 May 2024 07:26:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!WICt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Khi m&#7899;i t&#236;m hi&#7875;u v&#7873; web3 m&#236;nh th&#7845;y c&#361;ng c&#243; kh&#225; nhi&#7873;u c&#244;ng c&#7909; gi&#250;p ch&#250;ng ta ph&#225;t tri&#7875;n SC (smartcontract) nh&#432; Truffle, HardHat, Foundry. Trong s&#7889; &#273;&#243; m&#236;nh th&#7845;y Foundry kh&#225; d&#7877; d&#224;ng trong vi&#7879;c ti&#7871;p c&#7853;n v&#224; s&#7917; d&#7909;ng, &#273;&#417;n gi&#7843;n b&#7903;i v&#236; Foundry kh&#244;ng c&#7847;n ph&#7843;i s&#7917; d&#7909;ng nh&#7919;ng &#273;o&#7841;n m&#227; js &#273;&#7875; deploy/test/debug c&#225;c SC m&#224; thay v&#224;o &#273;&#243; l&#224; s&#7917; d&#7909;ng lu&#244;n nh&#7919;ng &#273;o&#7841;n m&#227; solidity. Ngo&#224;i ra Foundry c&#361;ng &#273;&#432;&#7907;c s&#7917; d&#7909;ng b&#7903;i c&#225;c hacker &#273;&#7875; build PoC cho nh&#7919;ng l&#7895; h&#7893;ng h&#7885; ph&#225;t hi&#7879;n. Th&#244;ng tin &#273;&#7847;y &#273;&#7911; c&#225;c b&#7841;n c&#243; th&#7875; tham kh&#7843;o th&#234;m t&#7841;i <a href="https://book.getfoundry.sh/">https://book.getfoundry.sh/</a></p><p>&#272;&#7875; c&#224;i &#273;&#7863;t Foundry ch&#7881; c&#7847;n ch&#7841;y command d&#432;&#7899;i &#273;&#226;y:</p><blockquote><p>curl -L https://foundry.paradigm.xyz | bash</p></blockquote><p>Sau &#273;&#243; ch&#7841;y: foundryup</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WICt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WICt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 424w, https://substackcdn.com/image/fetch/$s_!WICt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 848w, https://substackcdn.com/image/fetch/$s_!WICt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 1272w, https://substackcdn.com/image/fetch/$s_!WICt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WICt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png" width="1332" height="534" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:534,&quot;width&quot;:1332,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!WICt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 424w, https://substackcdn.com/image/fetch/$s_!WICt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 848w, https://substackcdn.com/image/fetch/$s_!WICt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 1272w, https://substackcdn.com/image/fetch/$s_!WICt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed5b73e4-bb91-4b35-9523-3e3f9acb3a2f_1332x534.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p>forge:  build, compile, debug, deploy  smart contracts.</p></li><li><p>cast: interact with the blockchain via RPC calls.</p></li><li><p>anvil: create local ethereum node.</p></li><li><p>chisel: solidity CLI shell for debugging.</p></li></ul><p>Kh&#7903;i t&#7841;o m&#7897;t project s&#7917; d&#7909;ng forge.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7Kkx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7Kkx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 424w, https://substackcdn.com/image/fetch/$s_!7Kkx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 848w, https://substackcdn.com/image/fetch/$s_!7Kkx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 1272w, https://substackcdn.com/image/fetch/$s_!7Kkx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7Kkx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png" width="964" height="137" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e66ded28-b489-431b-be45-c8baa52ce2df_964x137.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:137,&quot;width&quot;:964,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!7Kkx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 424w, https://substackcdn.com/image/fetch/$s_!7Kkx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 848w, https://substackcdn.com/image/fetch/$s_!7Kkx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 1272w, https://substackcdn.com/image/fetch/$s_!7Kkx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe66ded28-b489-431b-be45-c8baa52ce2df_964x137.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>&#272;&#226;y l&#224; l&#7895;i do ch&#432;a config git.</p><blockquote><p>git config &#8211;global user.email "devtest@example.com"</p><p>git config &#8211;global user.email "devtest"</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iG4m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iG4m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 424w, https://substackcdn.com/image/fetch/$s_!iG4m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 848w, https://substackcdn.com/image/fetch/$s_!iG4m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 1272w, https://substackcdn.com/image/fetch/$s_!iG4m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iG4m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png" width="968" height="408" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:408,&quot;width&quot;:968,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!iG4m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 424w, https://substackcdn.com/image/fetch/$s_!iG4m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 848w, https://substackcdn.com/image/fetch/$s_!iG4m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 1272w, https://substackcdn.com/image/fetch/$s_!iG4m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27bd316a-5240-49d1-aca0-a04a6fc9148e_968x408.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Th&#7921;c hi&#7879;n build &#273;&#7875; ki&#7875;m tra xem c&#243; l&#7895;i hay kh&#244;ng.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!r0LS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!r0LS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 424w, https://substackcdn.com/image/fetch/$s_!r0LS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 848w, https://substackcdn.com/image/fetch/$s_!r0LS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 1272w, https://substackcdn.com/image/fetch/$s_!r0LS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!r0LS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png" width="535" height="109" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:109,&quot;width&quot;:535,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!r0LS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 424w, https://substackcdn.com/image/fetch/$s_!r0LS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 848w, https://substackcdn.com/image/fetch/$s_!r0LS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 1272w, https://substackcdn.com/image/fetch/$s_!r0LS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0388838-2c5d-48a0-867f-8033ddf6c90e_535x109.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>C&#7845;u tr&#250;c c&#7911;a m&#7897;t project.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sTPh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sTPh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 424w, https://substackcdn.com/image/fetch/$s_!sTPh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 848w, https://substackcdn.com/image/fetch/$s_!sTPh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 1272w, https://substackcdn.com/image/fetch/$s_!sTPh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sTPh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png" width="364" height="377" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:377,&quot;width&quot;:364,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!sTPh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 424w, https://substackcdn.com/image/fetch/$s_!sTPh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 848w, https://substackcdn.com/image/fetch/$s_!sTPh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 1272w, https://substackcdn.com/image/fetch/$s_!sTPh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00f1b4ba-ca4c-4a2f-aa06-8aa62c3d16fb_364x377.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p>lib: n&#417;i ch&#7913;a c&#225;c th&#432; vi&#7879;n, vd: OpenZeppelin.</p></li><li><p>script: d&#249;ng &#273;&#7875; deploy smartcontract l&#234;n network.</p></li><li><p>src: ch&#7913;a m&#227; ngu&#7891;n c&#7911;a smartcontract.</p></li><li><p>test: l&#224; n&#417;i vi&#7871;t c&#225;c unit-test cho smartcontract tr&#432;&#7899;c khi &#273;&#432;&#7907;c deploy l&#234;n network.</p></li><li><p>foundry.toml: n&#417;i ch&#7913;a th&#244;ng tin c&#7845;u h&#236;nh, vd: rpc url, key&#8230;vv.</p></li></ul><p>Vd: th&#7921;c hi&#7879;n deploy smartcontract l&#234;n U2U network.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0msk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0msk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 424w, https://substackcdn.com/image/fetch/$s_!0msk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 848w, https://substackcdn.com/image/fetch/$s_!0msk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 1272w, https://substackcdn.com/image/fetch/$s_!0msk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0msk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png" width="973" height="486" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:486,&quot;width&quot;:973,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!0msk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 424w, https://substackcdn.com/image/fetch/$s_!0msk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 848w, https://substackcdn.com/image/fetch/$s_!0msk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 1272w, https://substackcdn.com/image/fetch/$s_!0msk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fe887c6-8ccc-4fc8-8bc0-91de2e4f0aa6_973x486.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><p>forge create --rpc-url "https://rpc-nebulas-testnet.uniultra.xyz" --private-key "your_private_key" src/Test1.sol:Test1</p></blockquote><p>Sau khi deploy th&#224;nh c&#244;ng.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qA8V!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qA8V!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 424w, https://substackcdn.com/image/fetch/$s_!qA8V!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 848w, https://substackcdn.com/image/fetch/$s_!qA8V!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 1272w, https://substackcdn.com/image/fetch/$s_!qA8V!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qA8V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png" width="1131" height="175" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:175,&quot;width&quot;:1131,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!qA8V!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 424w, https://substackcdn.com/image/fetch/$s_!qA8V!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 848w, https://substackcdn.com/image/fetch/$s_!qA8V!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 1272w, https://substackcdn.com/image/fetch/$s_!qA8V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991086b2-f207-4a7e-aaa5-ed431628cb7e_1131x175.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Ki&#7875;m tra tr&#234;n explorer. V&#236; smartcontract ch&#432;a &#273;&#432;&#7907;c verify n&#234;n ch&#7881; hi&#7879;n th&#7883; &#7903; d&#7841;ng bytecode.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qBY1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qBY1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 424w, https://substackcdn.com/image/fetch/$s_!qBY1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 848w, https://substackcdn.com/image/fetch/$s_!qBY1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 1272w, https://substackcdn.com/image/fetch/$s_!qBY1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qBY1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png" width="1332" height="858" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:858,&quot;width&quot;:1332,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!qBY1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 424w, https://substackcdn.com/image/fetch/$s_!qBY1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 848w, https://substackcdn.com/image/fetch/$s_!qBY1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 1272w, https://substackcdn.com/image/fetch/$s_!qBY1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449e8b08-3b51-4035-a60c-e275842a489e_1332x858.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>&#272;&#7875; cho d&#7877; h&#236;nh dung h&#417;n,  ch&#250;ng ta s&#7869; th&#7921;c hi&#7879;n t&#7841;o m&#7897;t ERC20 token v&#224; th&#7921;c hi&#7879;n c&#225;c c&#244;ng vi&#7879;c nh&#432;: deploy, transfer,&#8230;vv.</p><p>S&#7917; d&#7909;ng l&#7841;i project TestCode &#273;&#227; t&#7841;o tr&#432;&#7899;c &#273;&#243;, c&#224;i th&#432; vi&#7879;n OpenZeppelin v&#7899;i c&#226;u l&#7879;nh:</p><blockquote><p>forge install OpenZeppelin/openzeppelin-contracts</p></blockquote><p>Ti&#7871;p theo s&#7869; t&#7841;o m&#7897;t file MyToken.sol n&#7857;m trong folder /src</p><ul><li><p>Token name: MyToken</p></li><li><p>Symbol: MTK</p></li><li><p>Decimals: 18</p></li></ul><pre><code>// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    address public owner;
    mapping(address=&gt;address) public owner_spender;

    constructor() ERC20("MyToken", "MTK") {
        _mint(msg.sender, 100000);
        owner = msg.sender;
    }

    function newAllowance(address _owner, address _spender) public {
        allowance(_owner, _spender);
        owner_spender[_owner] = _spender;
    }

    function newMint(address to, uint256 value) external{
        require(msg.sender == owner,"Not owner !!!");
        require(value &gt; 0,"Check Value Error !!!");
        _mint(to, value);
    }
}</code></pre><p>N&#243;i qua v&#7873; &#253; ngh&#297;a c&#7911;a &#273;o&#7841;n code n&#224;y: deployer account s&#7869; mint 100k token khi th&#7921;c hi&#7879;n deploy contract n&#224;y l&#234;n network v&#224; deployer account s&#7869; &#273;&#432;&#7907;c g&#225;n cho bi&#7871;n owner. Ngo&#224;i ra c&#243; &#273;&#7883;nh ngh&#297;a th&#234;m 2 function newMint v&#224; newAllowance.</p><ul><li><p>newAllowance: tracking approver &amp; spender</p></li><li><p>newMint: mint token (ch&#7881; cho ph&#233;p owner &#273;&#432;&#7907;c th&#7921;c hi&#7879;n)</p></li></ul><p>&#272;&#7875; deploy smartcontract c&#7847;n c&#243; chain network, s&#7869; c&#243; 2 option m&#224; foundry cung c&#7845;p:</p><ul><li><p><strong>fork network</strong>: deploy l&#234;n b&#7845;t k&#7923; network n&#224;o v&#236; foundry h&#7895; tr&#7907; fork.</p></li><li><p><strong>local test network</strong>: foundry s&#7917; d&#7909;ng anvil &#273;&#7875; t&#7841;o local network (anvil c&#361;ng h&#7895; tr&#7907; fork network b&#7845;t k&#7923; v&#7899;i any block number -&gt; kh&#225; l&#224; h&#7919;u &#237;ch cho vi&#7879;c test c&#225;c smartcontract &#273;&#227; &#273;&#432;&#7907;c deploy tr&#234;n mainnet)</p></li></ul><p>&#7902; &#273;&#226;y s&#7869; s&#7917; d&#7909;ng local test network. S&#7917; d&#7909;ng c&#226;u l&#7879;nh sau &#273;&#7875; t&#7841;o local network v&#224; t&#7841;o 4 EOA account:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Vu9M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Vu9M!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 424w, https://substackcdn.com/image/fetch/$s_!Vu9M!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 848w, https://substackcdn.com/image/fetch/$s_!Vu9M!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 1272w, https://substackcdn.com/image/fetch/$s_!Vu9M!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Vu9M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png" width="1097" height="693" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:693,&quot;width&quot;:1097,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!Vu9M!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 424w, https://substackcdn.com/image/fetch/$s_!Vu9M!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 848w, https://substackcdn.com/image/fetch/$s_!Vu9M!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 1272w, https://substackcdn.com/image/fetch/$s_!Vu9M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f92675-57b6-493d-bcf7-866131ceea81_1097x693.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p>EOA(0) : deployer/owner 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266</p></li><li><p>EOA(1) : user1 0x70997970C51812dc3A010C7d01b50e0d17dc79C8</p></li><li><p>EOA(2) : user2 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC</p></li><li><p>EOA(3) : user3 0x90F79bf6EB2c4f870365E785982E1f101E93b906</p></li></ul><p>rpc url l&#250;c n&#224;y l&#224;: http://127.0.0.1:8545 (gi&#225; tr&#7883; n&#224;y c&#243; th&#7875; c&#7845;u h&#236;nh lu&#244;n trong file foundry.toml)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!agy2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!agy2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 424w, https://substackcdn.com/image/fetch/$s_!agy2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 848w, https://substackcdn.com/image/fetch/$s_!agy2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 1272w, https://substackcdn.com/image/fetch/$s_!agy2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!agy2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png" width="486" height="252" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:252,&quot;width&quot;:486,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!agy2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 424w, https://substackcdn.com/image/fetch/$s_!agy2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 848w, https://substackcdn.com/image/fetch/$s_!agy2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 1272w, https://substackcdn.com/image/fetch/$s_!agy2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1178a1cf-8634-4612-85fd-58cdab21646f_486x252.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>gi&#225; tr&#7883; PRIVATE_KEY ch&#237;nh l&#224; privatekey c&#7911;a EOA(0) account hay ch&#237;nh l&#224; deployer account.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Fsv8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Fsv8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 424w, https://substackcdn.com/image/fetch/$s_!Fsv8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 848w, https://substackcdn.com/image/fetch/$s_!Fsv8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 1272w, https://substackcdn.com/image/fetch/$s_!Fsv8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Fsv8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png" width="823" height="142" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:142,&quot;width&quot;:823,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!Fsv8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 424w, https://substackcdn.com/image/fetch/$s_!Fsv8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 848w, https://substackcdn.com/image/fetch/$s_!Fsv8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 1272w, https://substackcdn.com/image/fetch/$s_!Fsv8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4245aa77-3329-4188-bd8f-57caf03ffb15_823x142.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Sau khi &#273;&#227; t&#7841;o test network, ti&#7871;n h&#224;nh deploy MyToken.sol, trong folder /script t&#7841;o m&#7897;t file Deploy.s.sol.</p><pre><code>// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";
import {MyToken} from "../src/MyToken.sol";

contract Deploy is Script {
    function setUp() public {}

    function run() public {
        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); //l&#7845;y t&#7915; bi&#7871;n m&#244;i tr&#432;&#7901;ng
        vm.startBroadcast(deployerPrivateKey);
        // Make a new token ~ deploy
        MyToken mtk = new MyToken();
        vm.stopBroadcast();
        //vm.broadcast();
    }
}</code></pre><p>vm.startBroadcast (cheatcode: https://book.getfoundry.sh/cheatcodes/start-broadcast).</p><p>T&#7841;i sao l&#7841;i s&#7917; d&#7909;ng startBroadcast l&#224; b&#7903;i v&#236; khi deploy m&#7897;t smartcontract th&#236; EOA account s&#7869; sinh ra transaction v&#224; c&#7847;n sign (s&#7917; d&#7909;ng privatekey) transaction &#273;&#243;. Do &#273;&#243; transaction s&#7869; &#273;&#432;&#7907;c k&#253; b&#7903;i EOA(0).</p><p>Ch&#7841;y c&#226;u l&#7879;nh sau &#273;&#7875; deploy:</p><blockquote><p>forge script ./script/Deploy.s.sol --broadcast -vvvv --rpc-url rpcapi</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pSIn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pSIn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 424w, https://substackcdn.com/image/fetch/$s_!pSIn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 848w, https://substackcdn.com/image/fetch/$s_!pSIn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 1272w, https://substackcdn.com/image/fetch/$s_!pSIn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pSIn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png" width="1456" height="397" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:397,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!pSIn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 424w, https://substackcdn.com/image/fetch/$s_!pSIn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 848w, https://substackcdn.com/image/fetch/$s_!pSIn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 1272w, https://substackcdn.com/image/fetch/$s_!pSIn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a299b2-c818-4929-b8bb-87b9658f514e_1509x411.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Deployed Contract Address: 0x5FbDB2315678afecb367f032d93F642f64180aa3</p><p>Nh&#432; v&#7853;y &#273;&#227; deploy contract MyToken th&#224;nh c&#244;ng, ti&#7871;p theo s&#7869; t&#432;&#417;ng t&#225;c v&#7899;i contract n&#224;y nh&#432; th&#7871; n&#224;o ? &#7902; &#273;&#226;y s&#7869; vi&#7871;t test script &#273;&#7875; t&#432;&#417;ng t&#225;c (tham kh&#7843;o: <a href="https://book.getfoundry.sh/forge/writing-tests">writing-testa</a>)</p><p>Trong folder /test t&#7841;o 1 file MyTokenTest.t.sol</p><pre><code>// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console2} from "forge-std/Test.sol";
import {MyToken} from "../src/MyToken.sol";
import "forge-std/console.sol";

contract MyTokenTest is Test {
    function setUp() public {}
    function test_Transfer() public {
        // user accounts
        address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; //EOA(0)
        address user1 = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; //EOA(1)
        address user2 = 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC; //EOA(2)
        address user3 = 0x90F79bf6EB2c4f870365E785982E1f101E93b906; //EOA(3)
        // fork from local network
        uint256 rpcapi = vm.createFork("rpcapi");
        vm.selectFork(rpcapi);
    }</code></pre><p>Test script s&#7869; kh&#244;ng update storage tr&#234;n network, m&#224; n&#243; ch&#7881; &#273;&#417;n thu&#7847;n fork network xong v&#224; run trong m&#7897;t isolated EVM. V&#236; l&#250;c deploy contract &#273;&#227; th&#7921;c hi&#7879;n lu&#244;n mint 100k token cho t&#224;i kho&#7843;n owner, th&#7917; ki&#7875;m tra xem t&#224;i kho&#7843;n &#273;&#243; &#273;&#227; c&#243; 100k token hay ch&#432;a.</p><blockquote><p>forge test --match-contract MyTokenTest --match-test test_Transfer -vvv</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JEh2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JEh2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 424w, https://substackcdn.com/image/fetch/$s_!JEh2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 848w, https://substackcdn.com/image/fetch/$s_!JEh2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 1272w, https://substackcdn.com/image/fetch/$s_!JEh2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JEh2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png" width="1070" height="713" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:713,&quot;width&quot;:1070,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!JEh2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 424w, https://substackcdn.com/image/fetch/$s_!JEh2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 848w, https://substackcdn.com/image/fetch/$s_!JEh2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 1272w, https://substackcdn.com/image/fetch/$s_!JEh2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89c48b2e-d573-4b48-85b0-c1df4acb2d46_1070x713.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Mint 5k token cho c&#225;c t&#224;i kho&#7843;n user1-&gt;user3.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LHB3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LHB3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 424w, https://substackcdn.com/image/fetch/$s_!LHB3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 848w, https://substackcdn.com/image/fetch/$s_!LHB3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 1272w, https://substackcdn.com/image/fetch/$s_!LHB3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LHB3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png" width="942" height="628" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:628,&quot;width&quot;:942,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!LHB3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 424w, https://substackcdn.com/image/fetch/$s_!LHB3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 848w, https://substackcdn.com/image/fetch/$s_!LHB3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 1272w, https://substackcdn.com/image/fetch/$s_!LHB3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c653f4c-ede1-45f8-bfb4-7ab4ff612889_942x628.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Chuy&#7875;n 100 token t&#7915; t&#224;i kho&#7843;n t&#7915; user2 t&#7899;i user3.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qPW5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qPW5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 424w, https://substackcdn.com/image/fetch/$s_!qPW5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 848w, https://substackcdn.com/image/fetch/$s_!qPW5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 1272w, https://substackcdn.com/image/fetch/$s_!qPW5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qPW5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png" width="946" height="550" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:550,&quot;width&quot;:946,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!qPW5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 424w, https://substackcdn.com/image/fetch/$s_!qPW5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 848w, https://substackcdn.com/image/fetch/$s_!qPW5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 1272w, https://substackcdn.com/image/fetch/$s_!qPW5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16e4a161-4ae2-44c7-9adb-b5d66a44418a_946x550.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>user3 approve cho user1 chuy&#7875;n 1000 token t&#7915; user3 t&#7899;i user1.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!M-z8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!M-z8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 424w, https://substackcdn.com/image/fetch/$s_!M-z8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 848w, https://substackcdn.com/image/fetch/$s_!M-z8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 1272w, https://substackcdn.com/image/fetch/$s_!M-z8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!M-z8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png" width="829" height="448" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:448,&quot;width&quot;:829,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!M-z8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 424w, https://substackcdn.com/image/fetch/$s_!M-z8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 848w, https://substackcdn.com/image/fetch/$s_!M-z8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 1272w, https://substackcdn.com/image/fetch/$s_!M-z8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98ff8d50-c6d9-40fe-8831-3898b6b04a7c_829x448.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>&#272;o&#7841;n test script &#273;&#7847;y &#273;&#7911;:</p><pre><code>    function test_Transfer() public {
        // user accounts
        address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; //EOA(0)
        address user1 = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; //EOA(1)
        address user2 = 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC; //EOA(2)
        address user3 = 0x90F79bf6EB2c4f870365E785982E1f101E93b906; //EOA(3)
        // fork from local network
        uint256 rpcapi = vm.createFork("rpcapi");
        vm.selectFork(rpcapi);
        //get contract MyToken
        MyToken mtk = MyToken(0x5FbDB2315678afecb367f032d93F642f64180aa3);
        //get token of owner account
        emit log_named_uint("Token of Owner is ", mtk.balanceOf(owner));
        emit log_named_uint("Token of user1 is ", mtk.balanceOf(user1));
        emit log_named_uint("Token of user2 is ", mtk.balanceOf(user2));
        emit log_named_uint("Token of user3 is ", mtk.balanceOf(user3));
        emit log("====&gt; Mint 5k token to each one of users");
        vm.startBroadcast(owner);
        mtk.newMint(user1, 5000);
        mtk.newMint(user2, 5000);
        mtk.newMint(user3, 5000);
        vm.stopBroadcast();
        emit log_named_uint("Token of user1 is ", mtk.balanceOf(user1));
        emit log_named_uint("Token of user2 is ", mtk.balanceOf(user2));
        emit log_named_uint("Token of user3 is ", mtk.balanceOf(user3));
        emit log("====&gt; Transfer 100 tokens from user2 to user3");
        vm.startBroadcast(user2);
        mtk.transfer(user3, 100);
        vm.stopBroadcast();
        emit log_named_uint("Token of user1 is ", mtk.balanceOf(user1));
        emit log_named_uint("Token of user2 is ", mtk.balanceOf(user2));
        emit log_named_uint("Token of user3 is ", mtk.balanceOf(user3));
        // From user3 approve user1 to spend 1k tokens
        emit log("====&gt; user3 approve user1 to transfer 1000 token");
        vm.startBroadcast(user3);
        emit log_named_address("Approver", user3);
        mtk.approve(user1, 1000);
        mtk.newAllowance(user3, user1);
        emit log_named_address("spender", mtk.owner_spender(user3));
        vm.stopBroadcast();
        emit log("===&gt; user1 transfer 1000 tokens from user3 to user1");
        vm.startBroadcast(user1);
        mtk.transferFrom(user3, user1, 1000);
        vm.stopBroadcast();
        emit log("-&gt; After transfered");
        emit log_named_uint("Token of user1 is ", mtk.balanceOf(user1));
        emit log_named_uint("Token of user2 is ", mtk.balanceOf(user2));
        emit log_named_uint("Token of user3 is ", mtk.balanceOf(user3));
        
    }</code></pre><p>Qua &#273;&#243; ch&#250;ng ta c&#243; th&#7875; th&#7845;y s&#7917; d&#7909;ng foundry &#273;&#7875; l&#224;m vi&#7879;c v&#7899;i smartcontract &#273;em l&#7841;i thu&#7853;n ti&#7879;n, ch&#7881; c&#7847;n code solidity r&#7845;t d&#7877; nh&#7899;. Ngo&#224;i ra foundry h&#7895; tr&#7907; kh&#225; nhi&#7873;u cheatcode h&#7919;u &#237;ch kh&#225;c, c&#225;c b&#7841;n c&#243; tham kh&#7843;o t&#7841;i trang ch&#7911; &#273;&#7875; hi&#7875;u r&#245; h&#417;n c&#225;ch d&#249;ng.</p><p></p>]]></content:encoded></item><item><title><![CDATA[Vulnerability Severity Classification System]]></title><description><![CDATA[The Vulnerability Severity Classification System is referenced based on Immunefi.]]></description><link>https://blog.u2sec.io/p/vulnerability-severity-classification</link><guid isPermaLink="false">https://blog.u2sec.io/p/vulnerability-severity-classification</guid><dc:creator><![CDATA[u2sec]]></dc:creator><pubDate>Wed, 01 May 2024 23:34:35 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!3HK4!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe21c4d90-9823-46a2-b3b3-68979ac070bc_667x667.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Bugs are classified on a simplified 4-level scale:</p><ul><li><p>Critical</p></li><li><p>High</p></li><li><p>Medium</p></li><li><p>Low</p></li></ul><p>The development of this scale took into consideration multiple factors that may affect a vulnerability and its likelihood of exploitation, but finalizes them largely by the impact that they cause.</p><h3><strong>Blockchain/DLT</strong></h3><ul><li><p><strong>Critical:</strong></p><ul><li><p>Network not being able to confirm new transactions (total network shutdown)</p></li><li><p>Unintended permanent chain split requiring hard fork (network partition requiring hard fork)</p></li><li><p>Direct loss of funds</p></li><li><p>Permanent freezing of funds (fix requires hardfork)</p></li></ul></li><li><p><strong>High:</strong></p><ul><li><p>Unintended chain split (network partition)</p></li><li><p>Temporary freezing of network transactions by delaying one block by 500% or more of the average block time of the preceding 24 hours beyond standard difficulty adjustments</p></li><li><p>Causing network processing nodes to process transactions from the mempool beyond set parameters</p></li><li><p>RPC API crash affecting projects with greater than or equal to 25% of the market capitalization on top of the respective layer</p></li></ul></li><li><p><strong>Medium:</strong></p><ul><li><p>Increasing network processing node resource consumption by at least 30% without brute force actions, compared to the preceding 24 hours</p></li><li><p>Shutdown of greater than or equal to 30% of network processing nodes without brute force actions, but does not shut down the network</p></li><li><p>A bug in the respective layer 0/1/2 network code that results in unintended smart contract behavior with no concrete funds at direct risk</p></li></ul></li><li><p><strong>Low</strong>:</p><ul><li><p>Shutdown of greater than 10% or equal to but less than 30% of network processing nodes without brute force actions, but does not shut down the network</p></li><li><p>Modification of transaction fees outside of design parameters</p></li></ul></li></ul><h3><strong>Smart Contracts</strong></h3><ul><li><p><strong>Critical</strong>:</p><ul><li><p>Manipulation of governance voting result deviating from voted outcome and resulting in a direct change from intended effect of original results</p></li><li><p>Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield</p></li><li><p>Direct theft of any user NFTs, whether at-rest or in-motion, other than unclaimed royalties</p></li><li><p>Permanent freezing of funds</p></li><li><p>Permanent freezing of NFTs</p></li><li><p>Unauthorized minting of NFTs</p></li><li><p>Predictable or manipulable RNG that results in abuse of the principal or NFT</p></li><li><p>Unintended alteration of what the NFT represents (e.g. token URI, payload, artistic content)</p></li><li><p>Protocol insolvency</p></li></ul></li><li><p><strong>High:</strong></p><ul><li><p>Theft of unclaimed yield</p></li><li><p>Theft of unclaimed royalties</p></li><li><p>Permanent freezing of unclaimed yield</p></li><li><p>Permanent freezing of unclaimed royalties</p></li><li><p>Temporary freezing of funds</p></li><li><p>Temporary freezing NFTs</p></li></ul></li><li><p><strong>Medium:</strong></p><ul><li><p>Smart contract unable to operate due to lack of token funds</p></li><li><p>Block stuffing</p></li><li><p>Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)</p></li><li><p>Theft of gas</p></li><li><p>Unbounded gas consumption</p></li></ul></li><li><p><strong>Low</strong>:</p><ul><li><p>Contract fails to deliver promised returns, but doesn't lose value</p></li></ul></li></ul><h3><strong>Websites and Apps</strong></h3><ul><li><p><strong>Critical</strong>:</p><ul><li><p>Execute arbitrary system commands</p></li><li><p>Retrieve sensitive data/files from a running server, such as:</p><ul><li><p>/etc/shadow</p></li><li><p>database passwords</p></li><li><p>blockchain keys (this does not include non-sensitive environment variables, open source code, or usernames)</p></li></ul></li><li><p>Taking down the application/website</p></li><li><p>Taking down the NFT URI</p></li><li><p>Taking state-modifying authenticated actions (with or without blockchain state interaction) on behalf of other users without any interaction by that user, such as:</p><ul><li><p>Changing registration information</p></li><li><p>Commenting</p></li><li><p>Voting</p></li><li><p>Making trades</p></li><li><p>Withdrawals, etc.</p></li></ul></li><li><p>Changing the NFT metadata</p></li><li><p>Subdomain takeover with already-connected wallet interaction</p></li><li><p>Direct theft of user funds</p></li><li><p>Malicious interactions with an already-connected wallet, such as:</p><ul><li><p>Modifying transaction arguments or parameters</p></li><li><p>Substituting contract addresses</p></li><li><p>Submitting malicious transactions</p></li></ul></li><li><p> Direct theft of user NFTs</p></li><li><p>Injection of malicious HTML or XSS through NFT metadata</p></li></ul></li><li><p><strong>High</strong>:</p><ul><li><p>Injecting/modifying the static content on the target application without JavaScript (persistent), such as:</p><ul><li><p>HTML injection without JavaScript</p></li><li><p>Replacing existing text with arbitrary text</p></li><li><p>Arbitrary file uploads, etc.</p></li></ul></li><li><p>Changing sensitive details of other users (including modifying browser local storage) without already-connected wallet interaction and with up to one click of user interaction, such as:</p><ul><li><p>Email or password of the victim, etc.</p></li></ul></li><li><p>Improperly disclosing confidential user information, such as:</p><ul><li><p>Email address</p></li><li><p>Phone number</p></li><li><p>Physical address, etc.</p></li></ul></li><li><p>Subdomain takeover without already-connected wallet interaction</p></li></ul></li><li><p><strong>Medium</strong>:</p><ul><li><p>Changing non-sensitive details of other users (including modifying browser local storage) without already-connected wallet interaction and with up to one click of user interaction, such as:</p><ul><li><p>Changing the first/last name of user</p></li><li><p>Enabling/disabling notifications</p></li></ul></li><li><p>Injecting/modifying the static content on the target application without JavaScript (reflected), such as:</p><ul><li><p>Reflected HTML injection</p></li><li><p>Loading external site data</p></li></ul></li><li><p>Redirecting users to malicious websites (open redirect)</p></li></ul></li><li><p><strong>Low</strong>:</p><ul><li><p>Changing details of other users (including modifying browser local storage) without already-connected wallet interaction and with significant user interaction, such as:</p><ul><li><p>Iframing leading to modifying the backend/browser state (must demonstrate impact with PoC)</p></li></ul></li><li><p>Taking over broken or expired outgoing links, such as:</p><ul><li><p>Social media handles, etc.</p></li></ul></li><li><p>Temporarily disabling user to access target site, such as:</p><ul><li><p>Locking up the victim from login</p></li><li><p>Cookie bombing, etc.</p></li></ul></li></ul></li></ul><p>Ref:</p><ul><li><p>https://immunefi.com/immunefi-vulnerability-severity-classification-system-v2-3/</p></li><li><p>https://immunefisupport.zendesk.com/hc/en-us/articles/13332717597585-Severity-Classification-System?utm_source=immunefi</p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://blog.u2sec.io/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://blog.u2sec.io/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Security Analysis of DeFi: Vulnerabilities, Attacks and Advances]]></title><description><![CDATA[INTRODUCTION]]></description><link>https://blog.u2sec.io/p/security-analysis-of-defi-vulnerabilities</link><guid isPermaLink="false">https://blog.u2sec.io/p/security-analysis-of-defi-vulnerabilities</guid><dc:creator><![CDATA[Doan]]></dc:creator><pubDate>Tue, 30 Apr 2024 13:07:19 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!3HK4!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe21c4d90-9823-46a2-b3b3-68979ac070bc_667x667.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<ol><li><p><strong>INTRODUCTION</strong></p></li></ol><p>The popularity of blockchain 2.0 technology has resulted in a wide range of related services. Decentralized finance (DeFi) is an example of a financial service built on blockchains to provide transaction transparency. From January 2020 to April 2022, the total value locked in DeFi climbs from $600 million to around $200 billio.. However, there was a sharp drop in May 2022, which caused us to ponder the safety of DeFi. Attacks have emerged gradually with the rapid development of DeFi. Security incidents against DeFi continue to proliferate, and there has been a lot of research to improve the security of blockchain.</p><ol start="2"><li><p><strong>BACKGROUND</strong></p><ul><li><p><strong>ETHEREUM</strong>: Ethereum is a public blockchain that uses the Turing-complete programming language, such as Solidity, to develop smart contracts. Anyone can deploy decentralized applications (dapps) on the Ethereum that can communicate with others, and the most popular financial field is DeFi, which provides a wide range of financial services. </p></li><li><p><strong>GAS</strong>: To avoid overuse of network resources, all transactions on Ethereum are paid a cost, and the total gas cost equals the amounts of gas multiplied by gasPrice. The user who proposes transactions sets the gasPrice, and the transaction is conducted earlier if the gasPrice is high. </p></li><li><p><strong>MINER - EXTRACTABLE VALUE (MEV)</strong>: It refers to the profit miners make by performing a series of operations on the blocks they mine, such as transaction inclusion, exclusion, and reordering. Miners reorder transactions to optimize the initial ordering of transactions. Earning additional ordering optimization (OO) fees is also a source of MEV.</p></li></ul></li><li><p><strong>ANALYSIS OF VULNERABILITIES</strong></p><ol><li><p>Data Security Vulnerabilities:</p><p><strong>Oracle Mechanism Vulnerabilities</strong>: The oracle is an automated service mechanism that allows the system to obtain off-chain asset data as input. </p><p><strong>Inappropriate Key Management</strong>: In the DeFi ecosystem, wallets are used to manage private keys, and authentication is based on private keys in most cases. However, even the safest hardware wallets have security issues [20] caused by the design. </p></li><li><p>Consensus Mechanism Vulnerabilities:</p><p><strong>Transaction Order Vulnerability</strong>: It means that attackers alter the initial sequence of transactions by leveraging the desire of miners for profit. The sandwich attack is an example, the attacker spies on the victim, and pays a higher gas fee to miners before the victim gets asset A, then sells A for arbitrage since the victim&#8217;s purchase boosts the price.</p><p><strong>Forking Vulnerability</strong>: Forking in DeFi is generally associated with transaction fee-based forks and time-bandit attacks [18]. Mining revenue incentivizes miners to perform normally, but the OO fee motivates them to reorder transactions in the block, enhancing the income.</p></li><li><p>Smart Contract Vulnerabilities:</p><p><strong>Suicidal and Greedy Contracts</strong>: Smart contracts usually include a provision enabling the owner to commit suicide if the contract is challenged. This suicide procedure can be carried out for any cause under the suicidal contract. Greedy contracts do not have functions related to extraction. The contract locks all ether and cannot withdraw. </p><p><strong>Block Info Dependency</strong>: In Ethereum, the discrepancy between successive blocks is valid when the timestamps are within 12 minutes. However, if the contract combines states in the block, the miner can control it for profit. <strong>Unchecked External Call:</strong> The return values and arguments of an external call can affect the states, and many contracts do not check the return value leads to errors. Multiple functions are nested, and the external call does not check the return value can go wrong. Smart contracts trade by using external call functions such as call() and send(). More crucially, a failed external call results in a transaction not being rolled back, which can cause logical effects.</p></li><li><p>Application Layer Vulnerabilities:</p><p><strong>Lending Market Imperfection</strong>: When the prices in the market are out of balance, it will result in bad debts for one of the participants in the market. To get more loans, attackers can boost the exchange rate on the oracle by modifying the real-time price-related status before the loan is made. <strong>Cryptocurrency Instability</strong>: The large fluctuations of cryptocurrencies come from many reasons, one of which is the Pump-and-Dump. The instability can easily trigger liquidation procedures. Exchanges have chosen stablecoin, which is tied to the price of real money, as the pricing standard to minimize losses, but they still exist as a risk. </p><p><strong>Design imperfection</strong>: The attackers make use of incorrectly configured functionality or specific convenience features of DeFi platform exchanges . Flash loan is designed as riskfree loans to be a convenient improvement to the loan that need to borrow the flash loan, exchange it for currency and repay the loan in an atomic transaction. </p><p><strong>Abusive Exposure Transaction</strong>: Exchanges disclose all transactions as soon as feasible to ensure complete behavioral transparency because off-chain matching services are not automated. Unfortunately, exchanges can restrict access to select users and launch denial of service attacks to dominate the market, audit transactions and even front run the orders.</p></li></ol></li><li><p><strong>CONCLUSION AND FUTURE DIRECTION</strong></p><p>The focus of this paper is on the security of DeFi, and we summarize a series of security risks of DeFi by analyzing their projects deployed in Ethereum. For each vulnerability, we explore its causes with real-world cases. Finally, we investigate the optimization options for decentralized finance and suggest possible future directions. </p><p>Comprehensive knowledge of security and risk problems is critical to improving blockchain and establishing powerful defense capabilities in practice. There is a strong possibility to combine static detection with dynamic supervision technologies to protect DeFi at the consensus mechanism, smart contract, and application levels for the future development of DeFi application security.</p><p></p><p></p><h2>References:</h2><ul><li><p>2022 IEEE International Conference on Blockchain (Blockchain)</p><p></p></li></ul><p></p></li></ol>]]></content:encoded></item></channel></rss>