bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 38쪽 중 16쪽
))
}
main()
```
# Introduction
Source: https://docs.initia.xyz/developers/introduction
This section outlines the basics of developing on Initia and the various
Interwoven Rollups.
# AI Track Guidance
Source: https://docs.initia.xyz/hackathon/ai-track-guidance
Use this page if you are building for the AI track and want a practical model
for how AI should fit into your Initia appchain architecture.
You do not need to run model inference onchain. In most projects, inference
will happen offchain, with the appchain handling the parts of the product that
need blockchain guarantees.
<CardGroup>
<Card title="Use AI Offchain" icon="robot">
Generate or transform content, make recommendations, power copilots or
agents, and run classification or summarization.
</Card>
<Card title="Use the Appchain" icon="diagram-project">
Store ownership and state, handle rewards and payments, enforce access or
reputation, and coordinate marketplaces or escrow.
</Card>
</CardGroup>
## External AI Services
You may use hosted model APIs in your project. If your project depends on a
third-party AI provider, plan to supply your own API key or backend
configuration for development and demos. For most hackathon teams, hosted APIs
are the fastest and most common way to add AI features.
<Warning>
**API key security:** If your project uses an external AI API, store secrets
in a local `.env` file or another secure secret manager. Do not commit API
keys to GitHub or expose them in your demo video, screenshots, or frontend
code.
</Warning>
If you need to add a model provider to your app, start with the official API
docs for your chosen service:
<CardGroup>
<Card title="OpenAI" icon="book-open" href="https://platform.openai.com/docs/quickstart">
API docs
</Card>
<Card title="Anthropic" icon="book-open" href="https://platform.claude.com/docs/en/api/overview">
API docs
</Card>
<Card title="Google Gemini" icon="book-open" href="https://ai.google.dev/docs">
API docs
</Card>
</CardGroup>
<Note>
For demos, it is acceptable to use mocked, cached, or pre-generated AI
outputs if you clearly disclose that setup. Judges will evaluate the
product, appchain integration, and overall user experience, not whether the
model itself is hosted onchain.
</Note>
# Builder Guide
Source: https://docs.initia.xyz/hackathon/builder-guide
Use this page after [Set Up Your Appchain](/hackathon/get-started). Select a
direction, prompt your AI agent, deploy, and verify real onchain
behavior.
Prerequisites:
* **Tools ready**: `weave`, `initiad`, and `minitiad` are installed and in your
PATH ([Step 6](/hackathon/get-started#step-6-ai-powered-initia-tool-setup-and-verification)).
* **Infrastructure live**: your rollup and OPinit/Relayer bots are running
([Step 8](/hackathon/get-started#step-8-setup-interwoven-bots)).
* **Gas Station keys imported**: your `gas-station` keys are available in the local keyrings
([Step 9](/hackathon/get-started#step-9-final-key-setup)).
## Recommended Flow
1. **Set Up Your Appchain**: Complete [Set Up Your Appchain](/hackathon/get-started) and launch your local environment.
2. **Select Your Path**: Decide whether to build your app from scratch or adapt a Blueprint.
3. **Build Your App with AI**: Implement your app and confirm it works onchain.
4. **Debug and Refine**: Fix frontend or onchain issues before packaging your project.
5. **Prepare Your Submission**: Complete [Submission Requirements](/hackathon/submission-requirements).
## Part 1: Select Your Path
You can either build your app from scratch with your AI agent or start from a
Blueprint that matches the native feature you want to implement.
<CardGroup>
<Card title="Build From Scratch" icon="hammer" href="#part-2-build-your-app-with-ai">
Start from a blank project and use the AI-assisted workflow below to build,
deploy, and verify your app.
</Card>
<Card title="Select Your Blueprint" icon="drafting-compass" href="#select-your-blueprint">
Start from a Blueprint that already maps to a supported native feature,
then adapt it into your own original project.
</Card>
</CardGroup>
<Note>
**Blueprint Path:** If you select a Blueprint, you can jump directly into
that tutorial. Come back to this page later for debugging help or official
references if you need them. After you adapt the Blueprint into your own
original app, use
[Submission Requirements](/hackathon/submission-requirements) to confirm your
final submission is complete.
</Note>
### Select Your Blueprint
To qualify for the hackathon prizes, your project must implement at least one
supported Native Feature. These Blueprints provide implementation patterns you
can adapt, or use as references while building your own concept.
<CardGroup>
<Card title="Blueprint 1: BlockForge Game (Auto-signing)" icon="wand-magic-sparkles" href="/hackathon/examples/move-game">
A high-frequency application where the blockchain handles logic silently in
the background. Users approve a session once, then continue interacting
without repeated wallet popups.
* **Native Feature:** [`Auto-signing`](/interwovenkit/features/autosign/introduction)
* **Best for:** Gaming, Microtransactions, High-frequency trading.
</Card>
<Card title="Blueprint 2: MiniBank (Interwoven Bridge)" icon="bridge" href="/hackathon/examples/evm-bank">
An application that allows users to move assets between Initia L1 and an
appchain without leaving the app.
* **Native Feature:** [`Interwoven Bridging`](/interwovenkit/features/transfers/deposit-withdraw)
* **Best for:** DeFi, Cross-chain payments, Multi-chain apps.
</Card>
<Card title="Blueprint 3: MemoBoard (Initia Usernames)" icon="user-group" href="/hackathon/examples/wasm-social">
An application that prioritizes human-readable identities, replacing
complex hex addresses with personal usernames.
* **Native Feature:** [`Initia Usernames`](/developers/developer-guides/integrating-initia-apps/usernames)
* **Best for:** Social apps, Peer-to-peer payments, Community apps.
</Card>
</CardGroup>
<Note>
**Originality matters:** Whether you build from scratch or adapt a Blueprint,
judges will look for clear custom logic, UX, and product differentiation.
</Note>
## Part 2: Build Your App with AI
### Funding Your Personal Wallet
Before you can interact with your appchain via a browser wallet (like Keplr,
Leap, or MetaMask), you need to fund your personal address from your Gas
Station.
1. Copy your wallet address (`init1...`).
2. Ask your AI agent to fund your wallet:
```terminal title="Prompt: Fund your personal wallet" wrap theme={null}
Using the `initia-appchain-dev` skill, please fund my personal wallet <YOUR_WALLET_ADDRESS> with 1 INIT on L1 and 100 of my appchain's native tokens on L2.
```
### Development Workflow
1. **Describe the Goal**: Tell the AI what you want to achieve and why.
<Tip>
**Gather Submission Metadata Early:** As you build, keep track of the
deployed contract or module address and the final repo paths you plan to
submit for your core logic and native feature frontend files. You will use
them in the [Submission JSON](/hackathon/submission-requirements#submission-json).
</Tip>
2. **Build and Test**: Clearly describe your app's behavior and rules, then let
the AI write the code and unit tests.
```terminal title="Prompt: Create and test the contract" wrap theme={null}
Using the `initia-appchain-dev` skill, please create a new <MOVE / EVM / WASM> contract project in a directory named <PROJECT_NAME>, implement the core logic for <APP_NAME> with the following requirements:
<APP_REQUIREMENTS>
Please also create and run unit tests that verify both success and failure paths.
```
3. **Deploy to Your Appchain**: Instruct the AI to deploy your contract/module to your appchain.
```terminal title="Prompt: Deploy to your appchain" wrap theme={null}
Using the `initia-appchain-dev` skill, please build and deploy my contract/module from the <PROJECT_NAME> directory to my appchain using my Gas Station account.
If this VM requires instantiate after deploy, run that too, then return the deployed address.
```
4. **Verify Onchain Behavior**: Ask the AI to verify your live deployment with interactions and state queries.
```terminal title="Prompt: Smoke test live deployment" wrap theme={null}
Using the `initia-appchain-dev` skill, I want to smoke test my live <CONTRACT_NAME> on my appchain.
Please run 2-3 realistic user actions, then query state after each step and confirm the observed results match expected behavior.
```
5. **Integrate the Frontend**: Ask the AI to build or update your frontend and connect it to your appchain.
```terminal title="Prompt: Build the frontend" wrap theme={null}
Using the `initia-appchain-dev` skill, please create or update my frontend in <FRONTEND_PROJECT_NAME> to connect to my appchain with `InterwovenKit`, integrate my deployed <CONTRACT_OR_MODULE_NAME>, and implement the core user flow for <APP_NAME>.
```
<Note>
**Run the Frontend Locally:** After the frontend is implemented, follow
your AI agent's instructions to start the app locally and verify the core
user flow in the browser.
</Note>
6. **Add a Native Feature**: Ask the AI to implement one supported native feature and wire it into your app flow.
<Note>
**Supported Native Features:** To be eligible for prizes, your project
should implement at least one supported native feature. Select one of the
following:
* `auto-signing`
* `interwoven-bridge`
* `initia-usernames`
These features are covered in the Blueprint tutorials, but you can also
add them to a project you build from scratch.
</Note>
```terminal title="Prompt: Add a native feature" wrap theme={null}
Using the `initia-appchain-dev` skill, please add <AUTO-SIGNING / INTERWOVEN BRIDGE / INITIA USERNAMES> support to my app.
Please update the frontend and any required configuration so this native feature works in the core user flow.
```
## Part 3: Debugging & Troubleshooting
### Debugging Workflow
Whether you are building from scratch or adapting a Blueprint, errors are
inevitable.
1. **Open the Browser Console**: Press `F12` or `Cmd+Option+J` to see the exact
error logs.
2. **Provide Project Context**: Ensure your AI agent is open in your project root.
This allows it to reference your `package.json`, your `interwovenkit`
initialization, and your specific chain configuration.
3. **Evaluate and Fix the Error**: Ask your AI agent to fix the issue directly,
and include the exact console error in your prompt.
```terminal title="Prompt: Fix the error in my codebase" wrap theme={null}
Please find and fix this error directly in my codebase, then tell me what changed.
[PASTE_CONSOLE_ERROR]
```
## Part 4: Prepare Your Submission
Use [Submission Requirements](/hackathon/submission-requirements) to complete
your final submission files and confirm your project is eligible.
### Official References
* **Official Docs**: Visit [docs.initia.xyz](https://docs.initia.xyz/) for
architectural details and API references.
* **Initia Examples**: Reference the
[initia-labs/examples](https://github.com/initia-labs/examples) repository for
working code across all VMs (EVM, Move, Wasm).
* **Core Repositories**: Explore [initia-labs](https://github.com/initia-labs)
on GitHub to see the underlying implementation of the SDKs and CLI tools.
* **Initia L1**: [initia-labs/initia](https://github.com/initia-labs/initia)
contains the core Layer 1 source code.
* **Weave CLI**: [initia-labs/weave](https://github.com/initia-labs/weave) is
the main CLI for launching and managing appchains.
* **InterwovenKit**:
[initia-labs/interwovenkit](https://github.com/initia-labs/interwovenkit) is
the standard React SDK for Initia frontends.
* **Initia.js**: [initia-labs/initia.js](https://github.com/initia-labs/initia.js)
is the primary JavaScript library for blockchain interactions.
#### Useful Endpoints
* **Local Rollup Indexer:** `http://localhost:8080`
* **L1 Indexer Swagger:** `https://indexer.initia.xyz/swagger/index.html`
* **L1 Testnet RPC:** `https://rpc.testnet.initia.xyz`
* **L1 Testnet REST:** `https://rest.testnet.initia.xyz`
* **Faucet:** `https://faucet.testnet.initia.xyz`
# MiniBank - EVM
Source: https://docs.initia.xyz/hackathon/examples/evm-bank
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:
```text wrap Project Structure theme={null}
my-initia-project/
├── minibank/ # Solidity smart contract project
└── minibank-frontend/ # React frontend application
```
<Note>
**Prerequisite:** Ensure you have an EVM-compatible appchain running
locally. If you haven't launched one yet, complete the
[Set Up Your Appchain](../get-started) first.
</Note>
### Readiness Check
Before you start, verify that your local infrastructure is healthy.
```terminal title="Prompt: Check local infrastructure health" wrap theme={null}
Using the `initia-appchain-dev` skill, please verify that my appchain, executor bot, and relayer are running and that my Gas Station account has a balance.
```
## 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.
```terminal title="Prompt: Create and test the MiniBank contract" wrap theme={null}
Using the `initia-appchain-dev` skill, please create a Solidity smart contract project for our MiniBank in a new directory named `minibank`. The contract should:
- Allow users to deposit native tokens.
- Allow users to withdraw their own deposited tokens.
- Keep track of each user's total savings.
- Include a function to view the caller's current balance.
Please also create and run unit tests to verify these features.
```
Your AI agent will generate the `minibank` project and confirm that the tests
(likely using Foundry or Hardhat) pass successfully.
<Accordion title="Manual Approach: The Solidity Contract">
Initialize a Foundry project first:
```bash wrap Initialize Foundry Project theme={null}
# Use --no-git to avoid nested repos if you're already in a git project.
forge init minibank --no-git
cd minibank
```
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.
```solidity wrap src/MiniBank.sol theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract MiniBank {
mapping(address => uint256) private balances;
event Deposited(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
function deposit() public payable {
require(msg.value > 0, "Cannot deposit 0");
balances[msg.sender] += msg.value;
emit Deposited(msg.sender, msg.value);
}
function withdraw(uint256 amount) public {
require(amount > 0, "Withdrawal amount must be greater than zero");
require(balances[msg.sender] >= amount, "Insufficient balance");
balances[msg.sender] -= amount;
(bool success, ) = payable(msg.sender).call{value: amount}("");
require(success, "Transfer failed");
emit Withdrawn(msg.sender, amount);
}
function myBalance() public view returns (uint256) {
// NOTE: This returns the balance for the CALLER (msg.sender).
// In tests or frontend calls, ensure the correct account is the caller.
return balances[msg.sender];
}
function totalSavingsOf(address user) public view returns (uint256) {
// Helper to check the balance of any user without needing a 'from' address.
return balances[user];
}
receive() external payable {
deposit();
}
}
```
### Unit Testing with Foundry
To verify your contract's logic, create a test file named `MiniBank.t.sol` in
the `test` directory.
```solidity wrap test/MiniBank.t.sol theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "forge-std/Test.sol";
import "../src/MiniBank.sol";
contract MiniBankTest is Test {
MiniBank public bank;
address public user = address(0x123);
function setUp() public {
bank = new MiniBank();
vm.deal(user, 10 ether);
}
function testDeposit() public {
vm.prank(user);
bank.deposit{value: 1 ether}();
assertEq(bank.totalSavingsOf(user), 1 ether);
}
function testWithdraw() public {
vm.startPrank(user);
bank.deposit{value: 2 ether}();
bank.withdraw(1 ether);
assertEq(bank.totalSavingsOf(user), 1 ether);
vm.stopPrank();
}
function testWithdrawInsufficientBalance() public {
vm.prank(user);
bank.deposit{value: 1 ether}();
vm.prank(user);
vm.expectRevert("Insufficient balance");
bank.withdraw(2 ether);
}
}
```
Run your tests:
```bash wrap Run Foundry Tests theme={null}
forge test
```
</Accordion>
## 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.
```terminal title="Prompt: Deploy the MiniBank contract" wrap theme={null}
Using the `initia-appchain-dev` skill, please build, publish, and instantiate the MiniBank Solidity contract located in the `minibank` directory to my appchain using my Gas Station account, then return the deployed contract address.
```
<Accordion title="Manual Approach: Deploy via CLI">
First, compile your contract and extract the hex bytecode:
```bash wrap Compile And Extract Bytecode theme={null}
# Navigate to the contract directory
cd minibank
# Compile with Foundry
forge build
# Extract bytecode (requires jq)
# Ensure NO '0x' prefix and NO trailing newlines
jq -r '.bytecode.object' out/MiniBank.sol/MiniBank.json | tr -d '\n' | sed 's/^0x//' > minibank.bin
```
Then deploy the binary. **Find your Chain ID first** if you don't know it:
```bash wrap Get Chain ID theme={null}
# Query the appchain ID directly
curl -s http://localhost:26657/status | jq -r '.result.node_info.network'
```
Now deploy:
```bash wrap Deploy Contract theme={null}
# Replace `<YOUR_APPCHAIN_ID>` with the ID from the command above
minitiad tx evm create minibank.bin \
--from gas-station \
--keyring-backend test \
--chain-id <YOUR_APPCHAIN_ID> \
--node http://localhost:26657 \
--gas auto --gas-adjustment 1.4 --yes --output json > deploy.json
```
**Retrieve your contract address:** The output will provide a `txhash`. Wait a
few seconds for indexing, then find your contract address:
```bash wrap Get Contract Address theme={null}
# Replace <YOUR_TX_HASH> with the hash from deploy.json
minitiad q tx <YOUR_TX_HASH> --node http://localhost:26657 --output json | jq -r '.events[] | select(.type=="contract_created") | .attributes[] | select(.key=="contract") | .value'
```
</Accordion>
## 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.
```terminal title="Prompt: Smoke test the MiniBank contract" wrap theme={null}
Using the `initia-appchain-dev` skill, I want to smoke test our live MiniBank contract. Using my Gas Station account on my appchain, please:
1. Deposit 1 token.
2. Check my balance.
3. Withdraw 0.5 tokens.
4. Check my balance again.
```
<Accordion title="Manual Approach: On-Chain Interaction">
Call `deposit()` and send exactly `1` token in base units (`1e18` wei).
```bash wrap Deposit 1 Token theme={null}
DATA=$(cast calldata "deposit()")
minitiad tx프로젝트로 돌아가기