Skip to main content
This tutorial will guide you through building a liquidity-ready digital piggy bank on your EVM appchain. Users can deposit tokens, withdraw them, and access the broader Initia ecosystem via native bridging. By the end of this tutorial, you will have:
  • Generated and verified a Solidity smart contract for the bank logic.
  • Deployed the contract to your live appchain.
  • Scaffolded and connected a React frontend.
  • Verified the on-chain functionality.

Your Project Structure

The following steps will instruct your AI agent to create these directories inside your my-initia-project folder:
Project Structure
Prerequisite: Ensure you have an EVM-compatible appchain running locally. If you haven’t launched one yet, complete the Set Up Your Appchain first.

Readiness Check

Before you start, verify that your local infrastructure is healthy.
Prompt: Check local infrastructure health

Step 1: Create and Unit Test the Smart Contract

Instruct your AI agent to create the Solidity contract using the initia-appchain-dev skill. Your AI agent will generate the contract and automatically run unit tests to ensure the logic is sound.
Prompt: Create and test the MiniBank contract
Your AI agent will generate the minibank project and confirm that the tests (likely using Foundry or Hardhat) pass successfully.
Initialize a Foundry project first:
Initialize Foundry Project
If you prefer to create the contract manually, here is the Solidity code your AI agent would generate. Save this as MiniBank.sol in your minibank/src directory.
src/MiniBank.sol

Unit Testing with Foundry

To verify your contract’s logic, create a test file named MiniBank.t.sol in the test directory.
test/MiniBank.t.sol
Run your tests:
Run Foundry Tests

Step 2: Deploy to Your Appchain

Now that the logic is verified, build and publish the contract to your live appchain using the Gas Station account.
Prompt: Deploy the MiniBank contract
First, compile your contract and extract the hex bytecode:
Compile And Extract Bytecode
Then deploy the binary. Find your Chain ID first if you don’t know it:
Get Chain ID
Now deploy:
Deploy Contract
Retrieve your contract address: The output will provide a txhash. Wait a few seconds for indexing, then find your contract address:
Get Contract Address

Step 3: Smoke Test the Deployed Contract On-Chain

Before moving to frontend integration, smoke test the deployed contract directly on chain from the CLI. This isolates contract-level issues before UI work.
Prompt: Smoke test the MiniBank contract
Call deposit() and send exactly 1 token in base units (1e18 wei).
Deposit 1 Token
Query myBalance() as your sender account so msg.sender resolves correctly.
Query Balance
Call withdraw(uint256) with 0.5 token in base units (5e17 wei).
Withdraw 0.5 Tokens
Query myBalance() again to confirm the post-withdraw balance.
Query Balance Again

Step 4: Create a Frontend

Let’s create a simple UI to interact with our bank. 1. Scaffold the Frontend:
Prompt: Scaffold the MiniBank frontend
2. Connect to Appchain:
Prompt: Connect the frontend to the MiniBank contract
If you prefer to set up the frontend manually, follow these steps:1. Create the Project and Install Dependencies:
Create React App
2. Verify index.html: Vite scaffolding already creates index.html. Confirm it has this minimal structure in the root of your minibank-frontend directory:
index.html
3. Configure Vite Polyfills: Update vite.config.js to include the Node polyfills:
vite.config.js
4. Gather Runtime Values for Frontend Config: Before creating .env, collect the values you will use:
Gather Frontend Values
5. Create .env from Runtime Values:
Create Frontend Env
6. Set up Providers in main.jsx:
src/main.jsx
7. Create the App.jsx Layout:
src/App.jsx
8. Create the Bank.jsx Component: Create src/Bank.jsx and add the contract interaction logic.
msg.sender in view Calls: For view functions that depend on msg.sender (like myBalance), provide a from address in your eth_call params so the appchain resolves the correct user balance. This tutorial assumes 18 decimals, so parseEther/formatEther are used.
src/Bank.jsx

Step 5: Wallet Funding and UI Verification

Ask your AI agent to fund your browser wallet, then verify frontend behavior manually in the browser:
  1. Start the frontend:
Start Vite Dev Server
Check the browser console if you encounter issues.
  1. Open your browser wallet and copy your address (init1...).
  2. Give this prompt to your AI agent, replacing <YOUR_WALLET_ADDRESS> with the address you just copied:
  1. Connect your wallet in minibank-frontend.
  2. Test the full flow by depositing and withdrawing from the UI, then confirm the displayed savings state updates correctly after each action.
If you get stuck, see the Debugging Workflow guide.

🪢 Native Feature: Interwoven Bridge

Adding bridge support allows users to bring liquidity from the broader Initia ecosystem into your rollup. This transforms your appchain from an isolated sandbox into a connected part of the Interwoven Stack, providing users with a seamless UI to bridge tokens into your application for use.
Local Dev Limitation: The Interwoven UI only resolves registered chain IDs, so your local appchain and token may not appear during local testing. You can still add bridge functionality now. In your hackathon submission, explain the user flow (for example: bridge INIT or other assets from L1 to your appchain, then deposit them in MiniBank) and why this matters (faster onboarding, easier liquidity access, and immediate utility in your app).

Step 6: Update the Frontend

The useInterwovenKit() hook provides openBridge, which opens the bridge modal for moving assets between chains.
Prompt: Add Interwoven Bridge support
To implement this, update your src/Bank.jsx to include the bridge logic and UI:
Bridge Logic
If you want a complete end-state after the manual steps above, use the consolidated reference below.
This reference combines:
  • runtime config from .env,
  • InterwovenKit provider wiring in main.jsx,
  • wallet connect/display in App.jsx, and
  • live MiniBank interactions plus bridge entry point in Bank.jsx.
.env
.env
src/main.jsx
src/main.jsx
src/App.jsx
src/App.jsx
src/Bank.jsx
src/Bank.jsx
This reference assumes:
  • the deployed contract address is stored in .env as VITE_MINIBANK_CONTRACT,
  • sender in MsgCall uses bech32 (initiaAddress) lowercased,
  • EVM balance reads use JSON-RPC eth_call with a from hex address, and
  • the Vite dev server is restarted after any .env change.

Native Feature Verification

  1. Connect your wallet in minibank-frontend.
  2. Click Bridge Funds.
  3. Confirm the Interwoven Bridge modal opens.

Next Steps

Now that you’ve mastered an EVM application, you’re ready to build your own idea! Ensure your project meets all the Submission Requirements before submitting.