<titledata-rh="true">Using Foundry with Status Network | Status Network Documentation</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"property="og:locale"content="en_US"><metadata-rh="true"property="og:locale:alternate"content="zh_CN"><metadata-rh="true"property="og:locale:alternate"content="ko_KR"><metadata-rh="true"property="og:locale:alternate"content="ja_JP"><metadata-rh="true"name="docusaurus_locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="author"content="Status Network"><metadata-rh="true"property="og:image"content="https://docs.status.network/img/sn-social-card.png"><metadata-rh="true"property="og:url"content="https://docs.status.network"><metadata-rh="true"property="og:type"content="website"><metadata-rh="true"property="og:site_name"content="Status Network Documentation"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"name="twitter:site"content="@statusL2"><metadata-rh="true"name="twitter:title"content="Status Network Documentation"><metadata-rh="true"name="twitter:description"content="Documentation for Status Network - The gasless network with sustainable funding for app builders. Launch and scale your social apps and games with truly free transactions."><metadata-rh="true"name="twitter:image"content="https://docs.status.network/img/sn-social-card.png"><metadata-rh="true"name="docusaurus_version"content="current"><metadata-rh="true"name="docusaurus_tag"content="docs-default-current"><metadata-rh="true"name="docsearch:version"content="current"><metadata-rh="true"name="docsearch:docusaurus_tag"content="docs-default-current"><metadata-rh="true"property="og:title"content="Using Foundry with Status Network | Status Network Documentation"><metadata-rh="true"name="description"content="Comprehensive guide to deploying and testing smart contracts on Status Network using Foundry. Learn about project setup, deployment scripts, testing, and contract interaction using Cast."><metadata-rh="true"property="og:description"content="Comprehensive guide to deploying and testing smart contracts on Status Network using Foundry. Learn about project setup, deployment scripts, testing, and contract interaction using Cast."><metadata-rh="true"name="keywords"content="Foundry tutorial,smart contract deployment,Status Network development,blockchain testing,Solidity development,web3 development,Foundry testing"><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://docs.status.network/tutorials/deploying-contracts/using-foundry"><linkdata-rh="true"rel="alternate"href="https://docs.status.network/tutorials/deploying-contracts/using-foundry"hreflang="en-US"><linkdata-rh="true"rel="alternate"href="https://docs.status.network/zh/tutorials/deploying-contracts/using-foundry"hreflang="zh-CN"><linkdata-rh="true"rel="alternate"href="https://docs.status.network/ko/tutorials/deploying-contracts/using-foundry"hreflang="ko-KR"><linkdata-rh="true"rel="alternate"href="https://docs.status.network/ja/tutorials/deploying-contracts/using-foundry"hreflang="ja-JP"><linkdata-rh="true"rel="alternate"href="https://docs.status.network/tutorials/deploying-contracts/using-foundry"hreflang="x-default"><linkdata-rh="true"rel="preconnect"href="https://M7J93TRPJ9-dsn.algolia.net"crossorigin="anonymous"><linkrel="search"type="application/opensearchdescription+xml"title="Status Network Documentation"href="/opensearch.xml"><linkrel="stylesheet"href="/assets/css/styles.bb00a9fe.css">
<p>This tutorial will guide you through the process of deploying a smart contract on Status Network testnet using Foundry.</p>
<h2 class="anchoranchorWithStickyNavbar_LWe7"id="prerequisites">Prerequisites<ahref="#prerequisites"class="hash-link"aria-label="Direct link to Prerequisites"title="Direct link to Prerequisites"></a></h2>
<p>Before you begin, ensure you have the following:</p>
<ul>
<li><strong>Foundry</strong>: Install from the <ahref="https://book.getfoundry.sh/getting-started/installation"target="_blank"rel="noopener noreferrer">official Foundry book</a></li>
<li><strong>Ethereum Wallet</strong>: A private key for Status Network testnet</li>
<li><strong>Testnet ETH</strong>: You'll need Status Network testnet ETH<!-- -->
<ul>
<li>Get Status Network testnet ETH from our <ahref="/tools/testnet-faucets">Faucet</a></li>
</ul>
</li>
<li><strong>Basic Knowledge</strong>: Familiarity with Solidity and command line</li>
</ul>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="what-youll-accomplish">What You'll Accomplish<ahref="#what-youll-accomplish"class="hash-link"aria-label="Direct link to What You'll Accomplish"title="Direct link to What You'll Accomplish"></a></h2>
<ul>
<li>Initialize a Foundry project</li>
<li>Write a basic Ethereum smart contract</li>
<li>Configure Foundry for Status Network testnet deployment</li>
<li>Deploy your smart contract</li>
</ul>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="steps">Steps<ahref="#steps"class="hash-link"aria-label="Direct link to Steps"title="Direct link to Steps"></a></h2>
<h3class="anchor anchorWithStickyNavbar_LWe7"id="1-initialize-a-foundry-project">1. Initialize a Foundry Project<ahref="#1-initialize-a-foundry-project"class="hash-link"aria-label="Direct link to 1. Initialize a Foundry Project"title="Direct link to 1. Initialize a Foundry Project"></a></h3>
<h3class="anchor anchorWithStickyNavbar_LWe7"id="2-writing-the-smart-contract">2. Writing the Smart Contract<ahref="#2-writing-the-smart-contract"class="hash-link"aria-label="Direct link to 2. Writing the Smart Contract"title="Direct link to 2. Writing the Smart Contract"></a></h3>
<p>Replace <code>src/Counter.sol</code> with our <code>HelloWorld.sol</code>:</p>
<h3class="anchor anchorWithStickyNavbar_LWe7"id="3-configure-foundry-for-status-network">3. Configure Foundry for Status Network<ahref="#3-configure-foundry-for-status-network"class="hash-link"aria-label="Direct link to 3. Configure Foundry for Status Network"title="Direct link to 3. Configure Foundry for Status Network"></a></h3>
<p>Create or update <code>foundry.toml</code>:</p>
<h3class="anchor anchorWithStickyNavbar_LWe7"id="4-deploy-the-contract">4. Deploy the Contract<ahref="#4-deploy-the-contract"class="hash-link"aria-label="Direct link to 4. Deploy the Contract"title="Direct link to 4. Deploy the Contract"></a></h3>
<p>Create a deployment script <code>script/Deploy.s.sol</code>:</p>
<h3class="anchor anchorWithStickyNavbar_LWe7"id="5-interact-with-the-contract">5. Interact with the Contract<ahref="#5-interact-with-the-contract"class="hash-link"aria-label="Direct link to 5. Interact with the Contract"title="Direct link to 5. Interact with the Contract"></a></h3>
<p>Create a script to interact with your contract <code>script/Interact.s.sol</code>:</p>
<h3class="anchor anchorWithStickyNavbar_LWe7"id="6-cast-commands-for-quick-interactions">6. Cast Commands for Quick Interactions<ahref="#6-cast-commands-for-quick-interactions"class="hash-link"aria-label="Direct link to 6. Cast Commands for Quick Interactions"title="Direct link to 6. Cast Commands for Quick Interactions"></a></h3>
<p>You can also use <code>cast</code> to interact with your contract:</p>
<h3class="anchor anchorWithStickyNavbar_LWe7"id="7-testing">7. Testing<ahref="#7-testing"class="hash-link"aria-label="Direct link to 7. Testing"title="Direct link to 7. Testing"></a></h3>
<p>Create a test file <code>test/HelloWorld.t.sol</code>:</p>
<divclass="language-solidity codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-solidity codeBlock_bY9V thin-scrollbar"style="color:#bfc7d5;background-color:#292d3e"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">// SPDX-License-Identifier: MIT</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">pragma solidity ^0.8.24;</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">import "forge-std/Test.sol";</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">import "../src/HelloWorld.sol";</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">contract HelloWorldTest is Test {</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> HelloWorld hello;</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> function setUp() public {</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> hello = new HelloWorld();</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> }</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> function testGreeting() public {</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> assertEq(hello.getGreet(), "Hello, Status Network!");</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> hello.setGreet("New greeting");</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> assertEq(hello.getGreet(), "New greeting");</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> }</span><br></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="support">Support<ahref="#support"class="hash-link"aria-label="Direct link to Support"title="Direct link to Support"></a></h2>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="additional-resources">Additional Resources<ahref="#additional-resources"class="hash-link"aria-label="Direct link to Additional Resources"title="Direct link to Additional Resources"></a></h2>