Verona 백서

Verona

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 54쪽 중 36쪽

`bash git clone https://github.com/burnt-labs/brale-ach-demo.git cd brale-ach-demo ``` Install dependencies: ```bash pnpm install ``` ### Set Up Environment Variables Create your local environment file: ```bash cp .env.example .env ``` Generate an app session secret: ```bash openssl rand -base64 32 ``` Add the value to `.env`: ```bash AUTH_SECRET=your-generated-secret ``` Keep SQLite on the default path unless you want to store the local database somewhere else: ```bash SQLITE_PATH=./data/brale-demo.sqlite ``` The app creates the SQLite database and applies `sql/schema.sql` automatically on startup. ### Configure Verona Testnet The demo defaults to Verona testnet: ```bash NEXT_PUBLIC_XION_CHAIN_ID=xion-testnet-2 NEXT_PUBLIC_XION_RPC=https://rpc.xion-testnet-2.burnt.com NEXT_PUBLIC_XION_REST=https://api.xion-testnet-2.burnt.com ``` If you already have a Treasury contract or bank spend grant configured for your app, you can add it: ```bash NEXT_PUBLIC_TREASURY_ADDR= NEXT_PUBLIC_ABSTRAXION_BANK_GRANT_AMOUNT= ``` If no Treasury or bank grant is configured, cash-out falls back to direct wallet approval. ### Configure Brale Add your Brale credentials: ```bash BRALE_CLIENT_ID= BRALE_CLIENT_SECRET= BRALE_ACCOUNT_ID= ``` If you need to find your `BRALE_ACCOUNT_ID`, request a Brale access token and list accounts: ```bash TOKEN=$(curl -s -X POST "https://auth.brale.xyz/oauth2/token" \ -H "Authorization: Basic $(echo -n 'CLIENT_ID:CLIENT_SECRET' | base64)" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials" | jq -r '.access_token') curl -s "https://api.brale.xyz/accounts" \ -H "Authorization: Bearer $TOKEN" ``` For local testnet, keep these Brale transfer settings: ```bash BRALE_API_URL=https://api.brale.xyz BRALE_AUTH_URL=https://auth.brale.xyz BRALE_ALLOWED_TRANSFER_TYPES=xion_testnet,ach_debit,ach_credit,same_day_ach_credit,rtp_credit BRALE_SBC_TRANSFER_TYPE=xion_testnet BRALE_SBC_VALUE_TYPE=SBC BRALE_ACH_DEBIT_TYPE=ach_debit BRALE_ACH_CREDIT_TYPE=same_day_ach_credit NEXT_PUBLIC_BRALE_SBC_DENOM=factory/xion17grq736740r70awldugfs3mls3stu9haewctv2/sbc ``` The allowlist helps prevent accidentally using the wrong transfer type while testing. ### Run the App Locally Start the dev server: ```bash pnpm dev --hostname 127.0.0.1 ``` Open the app: ``` http://127.0.0.1:3000 ``` If port `3000` is busy, use another port: ```bash pnpm dev --hostname 127.0.0.1 --port 3001 ``` ### Connect with Abstraxion When the app opens: 1. Connect your Verona wallet. 2. Approve the login proof transaction. 3. The backend verifies the transaction memo through Verona REST. 4. The app creates a signed HTTP-only session cookie for the connected wallet. The login proof is a small 1 `uxion` self-transfer with a nonce memo. The server checks the sender, memo, and transaction hash before creating the session. ### Save KYC Details Before a user can link a bank account, the app stores basic KYC details: * Legal name * Email address * Phone number in E.164 format * Optional date of birth These details are stored locally in `brale_users` and sent to Brale when creating the Plaid Link token. ### Link a Bank Account Click **Link bank** to open Plaid Link through Brale. Behind the scenes: 1. The frontend calls `POST /api/brale/plaid/link-token`. 2. The backend sends the user's KYC details to Brale. 3. Brale returns a Plaid Link token. 4. The frontend opens Plaid Link. 5. After Plaid succeeds, the frontend calls `POST /api/brale/plaid/register`. 6. The backend exchanges the Plaid public token for a reusable Brale bank `address_id`. The app saves that bank `address_id` as `brale_users.plaid_bank_address_id`. ### Start an ACH On-Ramp ACH on-ramp moves USD from the user's linked bank account to SBC on their Verona wallet. In the demo: 1. The user enters a USD amount and clicks **Buy with ACH**. 2. The frontend calls `POST /api/brale/transfers` with: ```json { "kind": "onramp", "amountUsd": "5.00" } ``` 3. The backend verifies the user session, saved KYC, and linked bank. 4. The backend registers the user's Verona wallet as a Brale external address if needed. 5. The backend creates a local `brale_transfers` row. 6. The local transfer UUID is used as Brale's `Idempotency-Key`. 7. The backend creates a Brale transfer: ```json { "amount": { "value": "5.00", "currency": "USD" }, "source": { "address_id": "bank-address-id", "value_type": "USD", "transfer_type": "ach_debit" }, "destination": { "address_id": "wallet-address-id", "value_type": "SBC", "transfer_type": "xion_testnet" } } ``` The user does not need to sign an on-chain transaction for on-ramp because the source is the linked bank account. ### Start an ACH Off-Ramp ACH off-ramp moves SBC from the user's Verona wallet to USD in the linked bank account. In the demo: 1. The user enters an amount and clicks **Cash out to bank**. 2. The frontend calls `POST /api/brale/transfers` with: ```json { "kind": "offramp", "amountUsd": "5.00" } ``` 3. The backend creates a local transfer row and returns: ```json { "id": "local-transfer-id", "custodialBech32": "xion1...", "memo": "local-transfer-id", "sbcDenom": "factory/...", "microAmount": "5000000" } ``` 4. The frontend signs and broadcasts `sendTokens(wallet -> Brale custodial address)` with the memo. 5. The frontend PATCHes `/api/brale/transfers/{id}` with the on-chain transaction hash. 6. The backend creates a Brale transfer from custodial SBC to bank USD: ```json { "amount": { "value": "5.00", "currency": "USD" }, "source": { "address_id": "brale-custodial-address-id", "value_type": "SBC", "transfer_type": "xion_testnet" }, "destination": { "address_id": "bank-address-id", "value_type": "USD", "transfer_type": "same_day_ach_credit" } } ``` If a Treasury or bank spend grant is configured, the app tries Abstraxion session-key signing first. Otherwise, it reconnects the wallet signer and uses direct wallet approval. ### Configure Brale Webhooks Brale transfer creation returns a status such as `pending`. To know when a transfer is fully completed, configure Brale webhooks. Expose this endpoint to Brale: ``` POST https://your-domain.example.com/api/brale/webhook ``` For local testing, start a tunnel: ```bash ngrok http 3000 ``` Use the tunnel URL plus `/api/brale/webhook` when creating the Brale webhook subscription. Subscribe to: ``` transfer.completed ``` Save the returned webhook shared secret in `.env`: ```bash BRALE_WEBHOOK_SHARED_SECRET= ``` Restart the dev server after adding the secret. The webhook route: 1. Reads the raw request body. 2. Verifies `x-request-signature-sha-256` with HMAC-SHA256. 3. Stores the Brale event in `brale_webhook_events` for deduplication. 4. Updates the matching local transfer where `brale_transfer_id = event.data.id`. 5. Sets `status = complete` and fills `completed_at`. The dashboard also reconciles open transfers against Brale during refresh. This is useful for local development when webhooks are not yet reachable. ### Check Transfer Status in the Dashboard The **Recent transfers** table shows: * Transfer kind: on-ramp or off-ramp * USD amount * Current Brale status * Completion timestamp when available * Error messages if a transfer fails Pending transfers automatically refresh while the app is open. ### Copying the Flow into Another Verona App To add this flow to another Next.js app, copy the same boundaries rather than the whole UI: * `sql/schema.sql` tables for users, linked bank addresses, transfers, and webhook events. * `src/lib/brale-client.ts` for Brale authentication, request helpers, and transfer-type validation. * `src/lib/brale-account.ts` for KYC, bank address, wallet address, and custodial address helpers. * `src/lib/brale-webhook.ts` for webhook signature verification and event processing. * `src/app/api/brale/**` routes for KYC, Plaid, transfers, and webhooks. * `src/lib/session.ts` and `src/lib/xion.ts` if your app needs wallet-only login. * The dashboard components as a reference for user-facing states. If your app already has authentication, replace `getSessionUser()` with your own user lookup. The Brale routes only need a stable user ID and wallet address. ### Production Notes Before using this in production: * Keep Brale client credentials server-only. * Use a narrow `BRALE_ALLOWED_TRANSFER_TYPES` allowlist. * Persist the local transfer row before calling Brale so retries reuse the same idempotency key. * Store Brale webhook events for deduplication. * Verify webhook signatures against the raw body. * Use Brale webhooks for final completion and status polling as a fallback. * Use mainnet Brale credentials and mainnet transfer types only when you are ready to move real funds. * Decide whether cash-out should use Abstraxion session-key grants, direct wallet signing, or both. ### Additional Resources * Verona Docs: [Welcome to Verona](/en) * Developer Portal: <https://dev.testnet.burnt.com> * Brale API Docs: <https://docs.brale.xyz> * Brale Webhook Events: <https://docs.brale.xyz/webhooks/webhook-events> * Brale Quick Start: <https://docs.brale.xyz/overview/quick-start/> * Demo Repository: <https://github.com/burnt-labs/brale-ach-demo> # Building for Production Deploy applications to **Verona Mainnet** after testing on `xion-testnet-2`. Product narrative uses **Verona**; chain and governance processes use **Verona** naming throughout this section. This section outlines the key differences between **Testnet** and **Mainnet**, the requirements for deployment, and best practices to ensure your contracts are approved and adopted by the community. On the Verona network, **Production** means deploying your app to **Mainnet**—the live network where real users and real value live. **Testnet** is like a **sandbox** or staging environment: you can deploy and test freely with no cost and no governance gates. When you're ready to go live, you deploy to Mainnet (Production) through a governed process. ## **Testnet: A Space for Development & Refinement** The **Verona Testnet** is a **permissionless** environment where developers can deploy and refine their contracts without restrictions. We encourage teams to: * **Test and iterate** their contracts before considering Mainnet deployment. * **Engage with the community** for feedback, allowing real users to test their apps and identify potential improvements. * **Ensure stability and security** by rigorously testing different scenarios and edge cases. By leveraging Testnet, developers can refine their apps to the highest standards before moving to Mainnet. ## **Mainnet: A Secure & Permissioned Environment** Unlike **Testnet**, the **Verona Mainnet is permissioned**, meaning contracts cannot be deployed freely. Instead, contracts must go through a [**governance proposal process**](/en/build-on-verona/building-for-production/deploying-to-mainnet/smart-contract-audits-process-costs-and-support), where the Verona community reviews and votes on whether a contract should be stored on-chain. To protect users and maintain the security of the network, **audited contracts** have the highest chance of being considered for approval. This ensures that **Mainnet** hosts only **secure and reliable** apps. ### **Governance & Audit Requirements** To increase the chances of passing governance and deploying on Mainnet, developers should: 1. **Use existing, battle-tested contracts** – Where possible, developers should build on top of widely used and audited contracts to simplify the review process. 2. **Engage with the community** – Early discussions with the community can help identify concerns and improve the likelihood of governance approval. 3. **Conduct a security audit** – A professional third-party audit is highly recommended to ensure the contract has no vulnerabilities. 4. **Follow the governance process** – Refer to [Smart Contract Audits: Process, Costs & Support](/en/build-on-verona/building-for-production/deploying-to-mainnet/smart-contract-audits-process-costs-and-support) and the [archived governance guide](/en/others/archived/governance/governance-process-to-deploying-smart-contracts-to-mainnet) for detailed steps. # Testnet: Your Development Playground The **Verona testnet** (`xion-testnet-2`) is a permissionless environment for building, testing, and refining applications before deploying to **Mainnet**. ## **Why Use Testnet?** Testnet serves as a critical step in the development process, offering: * **Permissionless Deployment** – No governance approval is required, allowing developers to freely deploy and test their contracts. * **Risk-Free Testing** – Transactions and contract interactions use test tokens, meaning no real assets are at stake. * **Community Feedback** – Engaging users early helps refine apps before Mainnet launch. * **Pre-Mainnet Validation** – Identifying and fixing issues beforehand increases the chances of passing Mainnet governance. ## **Testnet Resources** To begin building on testnet, set up your development environment using the [local environment setup guide](/en/build-on-verona/computation/local-development/setting-up-env/installation-prerequisites-setup-local-environment). You'll need $VERONA test tokens (Previously $XION) to interact with the network. These are free and available through [Requesting Testnet Tokens](/en/build-on-verona/references/testnet-tokens). Once funded, connect using [Public Endpoints & Resources](/en/build-on-verona/references/public-endpoints-and-resources#testnet-2). Monitor activity with [Block Explorers](/en/build-on-verona/references/block-explorers). For cross-chain functionality, explore [IBC Denoms](/en/build-on-verona/references/ibc-denoms). # Building with Audited & Battle-Tested Contracts To ensure security, efficiency, and a smoother path to **Mainnet** approval, developers should prioritize using **audited** and **battle-tested** smart contracts whenever possible. Instead of building everything from scratch, integrating **trusted, widely used contracts** as building blocks can reduce risks, lower costs, and increase the likelihood of governance approval. ## **Why Use Audited & Battle-Tested Contracts?** ### **Security & Reliability** Audited contracts provide verified security, having undergone professional reviews to identify and eliminate vulnerabilities. Battle-tested contracts offer proven reliability, having been extensively used and validated by the community over time. A prime example is the [**cw-plus**](https://github.com/CosmWasm/cw-plus) collection of contracts. While this repository previously housed all [**cw-20**](https://github.com/CosmWasm/cw-tokens) token contracts and various [**NFT**](https://github.com/CosmWasm/cw-nfts) standards, these have since been migrated to dedicated repositories. The cw-plus repository continues to serve as a valuable reference point, directing developers to these essential, community-proven contract implementations. ### **Lower Costs & Faster Development** Using pre-audited contracts offers significant advantages across your development lifecycle. First and foremost, it dramatically reduces costs - security audits are expensive, and building on verified code minimizes the amount of new code requiring review. This established foundation also streamlines governance approval for Mainnet deployment, as committees can more readily trust contracts with proven security credentials. Beyond cost savings, these battle-tested solutions accelerate development by providing ready-made functionality out of the box. Instead of reinventing core components, your team can focus their energy on creating unique, value-added features that differentiate your app. The cw-plus contracts exemplify this efficiency, offering standardized implementations that have been optimized through extensive real-world use. ## **Where to Find Reusable & Audited Contracts** Developers can leverage the following repositories to find contracts that are **audited, widely used, or community-validated**: ### **Verona Mainnet Contracts Repository** * [**Verona Contracts Repository**](https://github.com/burnt-labs/contracts) – This repository lists **all contracts deployed on Mainnet** along with their **Code IDs**, making it easy for developers to instantiate existing contracts instead of deploying new ones. * **Before using a contract on Mainnet, you should first test its equivalent on Testnet.** Ensure your integration works correctly before submitting a governance proposal for Mainnet deployment. Within the contracts repository you will see the version being used under the release column and the link will take you to the actual code you will need to deploy on Testnet. ### **Commonly Used CosmWasm Contracts** * [**CW-Plus**](https://github.com/CosmWasm/cw-plus) – Standardized CosmWasm contracts, including CW20 (tokens), CW721 (NFTs), multisigs, and more. * [**CW-Minus**](https://github.com/CosmWasm/cw-minus) – Lightweight alternatives to CW-Plus contracts with reduced complexity. * [**CW-Tokens**](https://github.com/CosmWasm/cw-tokens) – Specialized token contracts that expand on CW20 and CW721 standards. * [**Public Awesome CW-NFTs**](https://github.com/public-awesome/cw-nfts) – A collection of NFT-specific smart contracts that follow the CW721 standard. These repositories contain **battle-tested** smart contracts that have been used across multiple projects in the Cosmos ecosystem. The list does not end here and so we encourage exploring additional repositories for specialized needs. --- [Next Page](https://docs.verona.dev/en/llms-full.txt/1) # Deploying to Mainnet Verona **Mainnet** is a **permissioned** environment designed to host secure and community approved decentralized applications (apps). Unlike **Testnet**, deploying to **Mainnet** requires governance approval to ensure only **trusted, high-quality** contracts are stored on-chain. This section will guide you through the **Mainnet deployment process**, including governance requirements, security best practices, and contract storage policies. ## **Key Differences Between Testnet & Mainnet** | Feature | Testnet | Mainnet | | ------------------- | ---------------------------- | ---------------------------- | | **Deployment** | Open to all (permissionless) | Requires governance approval | | **Contract Audits** | Optional but recommended | **Mandatory** for approval | | **Security** | Experimental environment | High-security environment | | **Real Assets** | No (test tokens) | Yes (real value at stake) | ## **Mainnet Deployment Steps** To deploy a contract on **Mainnet**, developers must: * **Thoroughly test your contract(s) on Testnet.** * **Undergo a security audit** to validate the contract's safety. * **Create a** [**Signaling Proposal**](https://discourse.xion.burnt.com/c/govpros/mainnet-contract-deployments/6) and inform the community and encourage them to give feedback * **Submit a** [**governance proposal**](https://staking.burnt.com/governance) for community approval. * **Once approved, your contract will be stored on Mainnet.** For detailed steps on deploying your **Contracts** to **Mainnet** go through the following guide: ### Prerequisites <a href="#prerequisites" id="prerequisites"></a> Before deploying to mainnet, ensure you have: 1. Thoroughly tested your contract on testnet 2. Conducted security audits if necessary 3. $VERONA tokens in your wallet for deployment fees 4. The compiled `.wasm` file of your smart contract (must be identical to the version deployed and tested on testnet) ### Required Governance Steps <a href="#required-governance-steps" id="required-governance-steps"></a> Contract deployment on Verona mainnet requires following a governance process. Here are the mandatory steps: 1. **Create a Signaling Proposal** * Post your proposal in the [Mainnet Contract Deployments category](https://discourse.xion.burnt
프로젝트로 돌아가기