Verona 백서

Verona

원문

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

er: Addr, // Owner address (user or admin) pub created_at: Timestamp, pub updated_at: Timestamp, } ``` This structure supports two main types of storage: ### 1. User-Owned Documents These are records that individual users can create and manage themselves, such as profile data or quiz submissions. Each user’s access is limited to their own documents, while admins retain the ability to override or update any record if needed. Examples: * `user_profiles/xion1abc...` * `quiz_submissions/user1_quiz1` ### 2. Admin-Controlled Collections Reserved for system-level or shared data, only authorized addresses (like the contract admin or a configured role) can write to these collections. They are ideal for managing global or shared state across the app. Examples: * `quizzes/quiz_001` * `settings/platform_config` This model provides a clean and extensible foundation for building multi-user, multi-role apps with fine-grained control over data access, storage structure, and updates. ## Permission System The permission system provides fine-grained access control over data stored in the contract, allowing developers to define who can perform specific actions on each collection. Permissions are defined at the collection level, ensuring consistent rules for all documents within that namespace. ### Collection-Level Permissions Each collection can specify separate rules for the following actions: ```rust pub struct CollectionPermissions { pub create: PermissionLevel, pub update: PermissionLevel, pub delete: PermissionLevel, pub read: PermissionLevel, } ``` This means you can independently control who can **create**, **update**, **delete**, or **read** documents in any given collection. ### Permission Levels The following permission levels are supported: * **Anyone**: Open access to all users. * **AdminOnly**: Only the admin can perform the action. * **AllowList(Vec)**: Only specific addresses are allowed. * **DenyList(Vec)**: Everyone except the listed addresses are allowed. * **RequireRole(String)**: Only users with a specific role (e.g., "moderator") can perform the action. These flexible permission levels allow each collection to enforce tailored access rules based on user roles or specific address whitelisting/blacklisting. ### Role System The role system complements permissions by allowing role-based access control (RBAC). Roles are stored in a simple mapping: ```rust Map<Addr, Vec<String>> ``` This allows each address to have one or more assigned roles. * **Admin role**: Granted full access across all collections and operations. * **Custom roles**: Developers can define and assign roles such as "**verified\_tutor**", "**moderator**", or any application-specific designation. By combining the permission and role systems, dapps can implement sophisticated access models to manage both user-generated and system-controlled content in a secure and scalable way. *** ## Create an Instance of the DocuStore Contract There's no need to deploy your own version of the DocuStore contract on-chain as we've already done so for Testnet. > The **Code ID** for the latest deplosyment is **1,228** Each contract instance requires a **unique initialization message** based on its expected parameters. In the case of the **DocuStore** contract, an **admin** parameter which stores a Verona address is required. Set the contract's initialization message by executing the following in your terminal, swapping the address to a Verona address you own and would like to be the admin of the contract: ```bash MSG='{"admin":"xion1..."}' CODE_ID=1228 ``` Execute the following command updating the value for `--from` to your wallet address that will be executing the transaction: ```bash xiond tx wasm instantiate $CODE_ID "$MSG" \ --from "your-address-here" \ --label "todo app" \ --gas-prices 0.025uxion \ --gas auto \ --gas-adjustment 1.3 \ -y --no-admin \ --chain-id xion-testnet-2 \ --node https://rpc.xion-testnet-2.burnt.com:443 ``` Example output: ```bash gas estimate: 217976 code: 0 txhash: 235FFA25254D8E22BF24E6CCF4F0F3055D5B56D4529BC968B1FF36AB9EA7509D ``` Copy the `txhash` value for the next step. ### **Retrieve the Contract Address** <a href="#retrieve-the-contract-address" id="retrieve-the-contract-address"></a> Once a contract instance is created, it is assigned a **unique contract address**. Set the new transaction hash from the previous contract instantiation step: ```bash TXHASH="your-txhash-here" ``` Query the blockchain to get the **contract address**: ```bash CONTRACT=$(xiond query tx $TXHASH \ --node https://rpc.xion-testnet-2.burnt.com:443 \ --output json | jq -r '.events[] | select(.type == "instantiate") | .attributes[] | select(.key == "_contract_address") | .value') ``` Display the contract address: ```bash echo $CONTRACT ``` Example output: ```bash xion1svpts9q2ml4ahgc4tuu95w8cqzv988s6mf5mupt5kt56gvdnklks9hzar4 ``` ## Deploy a Treasury Contract <a href="#deploying-a-treasury-contract-for-gasless-transactions" id="deploying-a-treasury-contract-for-gasless-transactions"></a> Before integrating the **Abstraxion SDK** into the application, we first need to deploy a **Treasury Contract**. This contract facilitates **gasless transactions** for your smart contract by handling **fee grants** on behalf of users as well as allowing users to grant authorization(s) to your app to execute certain transactions on their behalf. ### Steps to Deploy a Treasury Contract <a href="#steps-to-deploy-a-treasury-contract" id="steps-to-deploy-a-treasury-contract"></a> 1. Login to the [Developer Portal](https://dev.testnet.burnt.com/). 2. Click the **"New Treasury"** button to create a new treasury contract instance. 3. **Select the appropriate configurations**. The following "**Fee Grant (Allowance)**" and "**Grant Config (Permission)**" sections gives a recommended configuration that works for the DocuStore app: #### **Allowance** <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2F0OZmEIqivBlHaT6DsIQt%2Fimage.png?alt=media&amp;token=ed2fea09-e245-49bb-9c7f-c14832cfd8e6" alt=""><figcaption></figcaption></figure> 1. Enter a **"Description"** in the respective field. This will reflect the intended purpose of the request. 2. For the **"Allowance Type"** select "**Basic Allowance**". 3. In the **"Spend Limit"** field, enter **`0.1`** and select `$VERONA` as the token. 4. Click the **"Save"** button to apply the configuration. #### **Permission** <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FqRd1ShK8Ov21Kc9O0BtC%2Fimage.png?alt=media&amp;token=4bacfe82-3b62-413f-af0a-5775ac620f6e" alt=""><figcaption></figcaption></figure> 1. Enter a description in the **"Description"** field. This will reflect the intended purpose of the permission request. This description will be displayed to users when they click **"Allow"** after connecting their account. 2. For the **"Permission Type"** field, select `Execute on a smart contract`. 3. In the **"Authorization Type"** field, select `Contract Execution Authorization`. 4. Enter the **contract address** in the **"Contract Address"** field — this should be the **DocuStore** smart contract created above. 5. You **must** select at least one of the following:: * **"Max Call"** – Limits the number of times a user can execute a transaction under this fee grant. * **"Max Funds"** – Specifies the maximum amount of funds allocated for covering transaction fees. * **"Both"** – Allows you to set both options. 6. Click the **"Add Contract Grant"** button to apply the configuration. 7. Then click the "**Save**" button which generates the "**Treasury Instance Preview**" #### **Treasury Params** <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FEl9iJyCYq2PWrRJipDqE%2Fimage.png?alt=media&amp;token=d0b86c60-dd73-4323-ae3a-8db9d75909b9" alt=""><figcaption></figcaption></figure> You will need to enter a `Redirect URL` along with an `ICON URL`. After those fields are set click the "**Create**" button to finally create the treasury contract instance. You will be taken to the dashboard where you will see the newly created Treasury Contract instance. You can click on an instance to get the treasury contract address which will be required for setting up the frontend. {% hint style="info" %} Learn more about Treasury Contracts [here](/en/build-on-verona/accounts/getting-started/treasury-contracts). {% endhint %} ## Todo App Data Structure This todo app interacts with the DocuStore smart contract by organizing data into three main collections. Each collection stores structured documents with user-specific data. ### Todos Collection ```javascript interface Todo { id: string; text: string; completed: boolean; createdAt: number; } ``` Each document in the `todos` collection represents an individual task. It includes basic task details, and timestamps. ### Profiles Collection ```javascript interface Profile { displayName: string; bio: string; avatar: string; socialLinks: { twitter?: string; github?: string; website?: string; }; } ``` The `profile` collection stores public facing user profile data such as name, bio, and social media links. ### Settings Collection ```javascript interface Settings { darkMode: boolean; notifications: boolean; language: string; timezone: string; } ``` The `settings` collection holds user preferences for customizing the application experience, including UI theme, notification toggles, and localization options. ## Building the Frontend <a href="#building-the-frontend" id="building-the-frontend"></a> We've created a frontend which is a [Next.js](https://nextjs.org/) application built to interact with the **DocuStore** smart contract that can be downloaded at <https://github.com/burnt-labs/todo-app-frontend>. It showcases how users can connect their wallets, create todo records, update their profile, app settings and query their data. ### Manual Installation <a href="#manual-installation" id="manual-installation"></a> You will first need to clone the repository: ```bash git clone https://github.com/burnt-labs/todo-app-frontend ``` After doing so you will have to change into the newly created directory and then execute the steps below. 1. Install dependencies: ```bash cd todo-app-frontend npm install ``` 2. Copy the **`.env.example`** file and name it **`.env.local`** and set the values with the correct information: ```javascript NEXT_PUBLIC_TREASURY_ADDRESS=your_treasury_address NEXT_PUBLIC_CONTRACT_ADDRESS=your_contract_address NEXT_PUBLIC_RPC_URL="https://rpc.xion-testnet-2.burnt.com:443" NEXT_PUBLIC_REST_URL="https://api.xion-testnet-2.burnt.com" ``` | Variable | Description | | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | NEXT\_PUBLIC\_TREASURY\_ADDRESS | Treasury contract instance used for gasless transactions and grantz authorization to execute transactions via the DocuStore smart contract instance on behalf of users. | | NEXT\_PUBLIC\_CONTRACT\_ADDRESS | Address of the DocuStore smart contract instance. | | NEXT\_PUBLIC\_RPC\_URL | RPC endpoint for Verona (default: `https://rpc.xion-testnet-2.burnt.com:443`) | | NEXT\_PUBLIC\_REST\_URL | REST endpoint for Verona (default: `https://api.xion-testnet-2.burnt.com`) | 3. Build and start the application: ``` npm run dev ``` You can now access the app at [http://localhost:3000](http://localhost:3000/) in your browser. <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FMM0yBgDl77KEli7fFdbQ%2Fimage.png?alt=media&amp;token=9627a94a-e2f8-49d9-840e-89a5134e14d6" alt=""><figcaption></figcaption></figure> # Build a TODO Mobile App using the DocuStore Contract To reduce the need for custom contract development and accelerate Web2 to Web3 migrations, we've created a contract that provides a **collection/document** based storage model, inspired by Firebase’s Firestore. It supports structured JSON data storage using a flexible key-value format and an a permission model. This solution is a major upgrade from the original `user_map` contract by enabling: * **Namespaced storage**: Data is organized into logical **collections** and **documents**. * **Permissioned access**: Fine-grained control over who can **`create`**, **`update`**, **`delete`**, and **`read`** documents. * **Role-based security**: Support for roles like "creator", "admin", and any custom roles. * **Batch operations**: Write multiple documents in a single transaction. ## Todo App Data Structure This todo app interacts with the **DocuStore** smart contract by organizing data into three main **collections**. Each collection stores structured documents with user-specific data. ### Todos Collection ```typescript type Todo = { id: string; title: string; text: string; completed: boolean; created_at: string; }; ``` Each document in the `todos` collection represents an individual task. It includes basic task details and timestamps. ### Profiles Collection ```typescript type Profile = { displayName: string; bio: string; avatar: string; socialLinks: { twitter?: string; github?: string; website?: string; }; }; ``` The `profile` collection stores public facing user profile data such as name, bio, image for an avatar and social media links. ### Settings Collection ```javascript interface Settings { darkMode: boolean; notifications: boolean; language: string; timezone: string; } ``` The `settings` collection holds user preferences for customizing the application experience, including UI theme, notification toggles, and localization options. ## Building the Mobile App <a href="#building-the-frontend" id="building-the-frontend"></a> We’ve created a [mobile app demo](https://github.com/burnt-labs/todo-app-expo-demo) built with [React Native](https://reactnative.dev/) and [Expo](https://expo.dev/) that includes all the necessary wiring to interact with the DocuStore smart contract. It demonstrates how users can connect their wallets, create todo items, update their profiles and app settings, and query their on-chain data. ### Manual Installation <a href="#manual-installation" id="manual-installation"></a> 1. You will first need to clone the repository: ```bash git clone https://github.com/burnt-labs/todo-app-expo-demo.git ``` 2. Install dependencies: ```bash cd todo-app-expo-demo npm install ``` 3. Copy the **`.env.example`** file and name it **`.env.local`** and set the values with the information below: ```javascript EXPO_PUBLIC_DOCUSTORE_CONTRACT_ADDRESS="xion1svpts9q2ml4ahgc4tuu95w8cqzv988s6mf5mupt5kt56gvdnklks9hzar4" EXPO_PUBLIC_TREASURY_CONTRACT_ADDRESS="xion1aza0jdzfc7g0u64k8qcvcxfppll0cjeer56k38vpshe3p26q5kzswpywp9" EXPO_PUBLIC_RPC_ENDPOINT="https://rpc.xion-testnet-2.burnt.com:443" EXPO_PUBLIC_REST_ENDPOINT="https://api.xion-testnet-2.burnt.com" ``` | Variable | Description | | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | EXPO\_PUBLIC\_TREASURY\_CONTRACT\_ADDRESS | Treasury contract instance used for gasless transactions and grantz authorization to execute transactions via the DocuStore smart contract instance on behalf of users. | | EXPO\_PUBLIC\_DOCUSTORE\_CONTRACT\_ADDRESS | Address of the DocuStore smart contract instance. | | EXPO\_PUBLIC\_RPC\_ENDPOINT | RPC endpoint for Verona (default: `https://rpc.xion-testnet-2.burnt.com:443`) | | EXPO\_PUBLIC\_REST\_ENDPOINT | REST endpoint for Verona (default: `https://api.xion-testnet-2.burnt.com`) | 4. Build and launch the application: To build and run the app, ensure your **emulator**, **simulator**, or **physical device** is running. Then, use one of the following commands based on your target platform to launch the App: {% tabs %} {% tab title="For Android" %} ```sh npx expo run:android ``` {% endtab %} {% tab title="For iOS" %} ```sh npx expo run:ios ``` {% endtab %} {% endtabs %} You should see something like the following for the **Home** page: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FM5AgDSP1AXyABIWRaDId%2FScreenshot_1750046917.png?alt=media&amp;token=4a2c7bed-f058-4634-b51c-5bbb193d0839" alt="" width="375"><figcaption></figcaption></figure> Here is a glimpse of the **Profile** page: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FozjNAMBja9NeEUnr1i5L%2FScreenshot_1750046929.png?alt=media&amp;token=34b0ac80-c949-458b-90e9-10fae643ffd3" alt="" width="375"><figcaption></figcaption></figure> This is the **Settings** page: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FD7tdXrPeTdbghkSIuGJy%2FScreenshot_1750046951.png?alt=media&amp;token=af08286b-6ee2-4a6e-a82d-c3497ba28eb5" alt="" width="375"><figcaption></figcaption></figure> # Verification This section covers how to integrate the **Truth Engine** into your application on the Verona network. Whether you are building a consumer app, an agent workflow that needs verified context, or a DeFi protocol that assesses creditworthiness, these guides walk through full integration. Conceptual background: [Truth Engine](/en/about-verona/verification-infrastructure) · Product surface: [Burnt Verified](/en/about-verona/surfaces/burnt-verified) ### ZK Infrastructure #### [Publishing ZK Verification Keys](/en/build-on-verona/verification/publishing-zk-verification-keys) Publish and manage verification keys (vkeys) for custom ZK circuits on the Verona network. This is **infrastructure-level** guidance for advanced use cases requiring custom ZK proving systems (Groth16, Gnark, UltraHonk). > **Note**: Most applications use pre-configured vkeys for standard verification features (zkTLS, zkEmail, App Attestations). This guide is for developers building custom ZK circuits. ### Explore the verification modules #### [Internet Verification (ZK Module, zkTLS)](/en/build-on-verona/verification/internet-verification) Verify data from any website using zero-knowledge proofs over TLS-encrypted sessions. Prove user credentials, financial data, and platform reputation without exposing sensitive information. * **Reclaim Integration**: Verify social media stats, financial data, and platform activity * **Opacity Integration**: Alternative zkTLS provider for internet verification #### Email Verification (DKIM Module, ZK Email) Verify email contents cryptographically using existing DKIM signatures. Prove purchase receipts, employment verification, and account ownership without accessing the user's inbox. ***(Guides coming soon)*** #### Mobile Verification (App Attestations) Verify mobile application data with cryptographic proofs. Prove rideshare ratings, fitness metrics, and app usage from mobile devices. ***(Guides coming soon)*** # Publishing ZK Verification Keys Publish and manage zero-knowledge verification keys on Verona using xiond This guide explains how to publish verification keys (vkeys) for zero-knowledge proving systems to Verona using the `xiond` CLI. Verification keys are a core component of the [Truth Engine](/en/about-verona/verification-infrastructure), enabling on-chain proof verification. ## Overview Before verifying zero-knowledge proofs on the Verona network, you must publish the corresponding verification key to the chain. Eac
프로젝트로 돌아가기