.init usernames.
By the end of this tutorial, you will have:
- Generated and verified a Rust smart contract for the guestbook.
- 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 yourmy-initia-project folder:
Project Structure
Prerequisite: Ensure you have a Wasm-compatible appchain running
locally. If you haven’t launched one yet, complete the
Step-by-Step Guide first.
Readiness Check
Before you start, verify that your local infrastructure is healthy. Prompt:Step 1: Create and Unit Test the Smart Contract
Instruct your AI agent to create the Rust (Wasm) contract using theinitia-appchain-dev skill. Your AI agent will generate the contract and
automatically run unit tests to ensure the logic is sound.
Example Prompt:
memoboard project and confirm that the Rust
tests pass.
Manual Approach: The Rust Contract
Manual Approach: The Rust Contract
If you prefer to see the Rust logic, here is a simplified but schema-accurate version of what your AI agent would generate. If doing this manually, save the following code in Important: Ensure your Also ensure
src/contract.rs inside your memoboard directory (ensure src/lib.rs exports the contract module).First create and enter the project directory:Cargo.toml includes the following [lib] section
to correctly generate the Wasm binary:Cargo.toml
Cargo.toml includes these dependencies and features required by
the example contract:Cargo.toml
src/contract.rs
Step 2: Deploy to your Appchain
Now that the logic is verified, build and publish the contract to your appchain using the Gas Station account. Prompt:Manual Approach: Deploy via CLI
Manual Approach: Deploy via CLI
1. Build and Store the Code:Standard The optimized binary will be located in 2. Retrieve the Code ID and Instantiate:If the Then, instantiate the contract:3. Retrieve the Contract Address:Wait for 5 seconds for indexing and then query the transaction hash:
cargo build binaries often fail validation on-chain. For WasmVM
deployment, it is strongly recommended to use the CosmWasm Optimizer.Note for Apple Silicon (M1/M2/M3): Use
cosmwasm/optimizer-arm64:0.17.0.Optimizer Build Command
./memoboard/artifacts/memoboard.wasm.
Now, store the code:Store Wasm Code
code_id is not returned directly, wait for 5 seconds for indexing and
then query the transaction hash:Get Code ID
Instantiate Contract
Get Contract Address
Step 3: Smoke Test the Deployed Contract On-Chain
Before frontend integration, smoke test your deployed contract directly on chain. Example Prompt:Manual Approach: On-Chain Interaction
Manual Approach: On-Chain Interaction
Submit one message transaction, then query contract state to confirm it was
persisted on chain.
Post Message
Query Messages
Step 4: Create a Frontend
Let’s create a UI to display and post messages. 1. Scaffold the Frontend:Manual Approach: Scaffold and Connect
Manual Approach: Scaffold and Connect
If you prefer to set up the frontend manually, follow these steps:1. Create the Project and Install Dependencies:2. Configure Vite Polyfills: Update Create the frontend files in this order so the imports line up cleanly:4. Add Runtime Configuration: Create a 5. Set up Providers in 6. Create the src/Board.jsx:7. Create
vite.config.js to include the Node
polyfills:vite.config.js
vite.config.js.envsrc/main.jsxsrc/Board.csssrc/Board.jsxsrc/App.jsx
.env,
collect the values you will use:Gather Frontend Values
.env file in memoboard-frontend
so the chain metadata, endpoints, and live contract address are explicit:.env
main.jsx:src/main.jsx
Board.jsx Component: Create src/Board.jsx and
src/Board.css with the following content:src/Board.css:src/Board.css
src/Board.jsx
App.jsx: Create the app shell that renders the board and owns the wallet button:src/App.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:- Start the frontend:
Start Vite Dev Server
- Open your browser wallet and copy your address (
init1...). - Give this prompt to your AI agent, replacing
<YOUR_WALLET_ADDRESS>with the address you just copied:
- Connect your wallet in
memoboard-frontend. - Post a message from the UI.
- Confirm it appears in the message list after refresh.
- If your UI supports it, verify sender identity rendering matches expectations.
⚡ Power-Up: Initia Usernames
To make your MemoBoard natively integrated with the Initia stack, you can replace long, complex addresses with human-readable Initia Usernames (e.g.,vitalik.init).
Step 6: Register your .init Name
Before updating your code, you should register aprimary username for your
wallet on the Initia testnet.
- Navigate to app.testnet.initia.xyz/usernames and connect your browser wallet.
- In the
Find a usernamesearch box, enter your desired name. If it is available, you will see a greenAvailablecheckmark. - Crucial: Ensure the
Set as primary namecheckbox is selected. - Click
Registerand approve the transaction. Once resolved, your new.initname will appear in the top-right corner of the Initia App.
Step 7: Update the Frontend
Your AI agent knows how to integrate Initia Usernames. Simply ask it to update your board. Example Prompt:Manual Approach: Username Resolution
Manual Approach: Username Resolution
The
useInterwovenKit() hook provides the username for the currently connected wallet, and useUsernameQuery(address) resolves usernames for other sender addresses. This requires @initia/interwovenkit-react 2.4.6 or newer. To implement this, update your wallet button component (for example src/App.jsx) and your board message list like this:Manual Approach: Final Frontend Reference
Manual Approach: Final Frontend Reference
If you want a single copyable end-state after completing the manual steps above, use this consolidated reference. It combines:src/App.jsx
- live Wasm contract query and execute flow,
- wallet connect/display via
App.jsx, - runtime config from
.env, and - Initia username support for the connected wallet and sender rows.
src/Board.jsx
src/App.jsx
Power-Up Verification
- Connect your wallet in
memoboard-frontend. - Confirm the header button shows your
.initusername (not only a truncated address). - Post a message and confirm the sender label for your message uses your username.