Verona 백서

Verona

원문

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

. 1. Go to <https://quickstart.dev.testnet.burnt.com> and log in using your **Meta Account** <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FkLbQrnyLcugWoZH4wXru%2Fimage.png?alt=media&amp;token=0ad0e7f8-1d48-4335-8e53-a5b0f08096fd" alt=""><figcaption></figcaption></figure> 2. Select "**User Map**" from **Step 1** and click the **Launch User Map & Fund Treasury** button under **Step 2**. <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FGQwE8ixtUc9ecgDVLksv%2Fimage.png?alt=media&amp;token=4b9821fe-c1c1-49a2-ab26-7b9ad59d8895" alt=""><figcaption></figcaption></figure> Behind the scenes, this: * Instantiates your **User Map** contract * Deploys a **Treasury contract** with a configured **Fee Grant** to enable gasless transactions and also **Authorization Grants** for users to give the frontend approval to interact with the **User Map** contract on their behalf * Funds the **Treasury contract** to pay transaction fees for users via the **Fee Grant** These 4 environment variables will be generated which will you will need to add to the frontend project `.env.local` [environment file](#set-up-environment-variables): ```env NEXT_PUBLIC_CONTRACT_ADDRESS=... NEXT_PUBLIC_TREASURY_ADDRESS=... NEXT_PUBLIC_RPC_URL=... NEXT_PUBLIC_REST_URL=... ``` ## Set Up the Frontend The frontend allows users to log into your app using their Meta Account via multiple authenticators (Email, Social Login, Wallets, Passkeys). Once logged in, users can query contract data and execute transactions to update their User Map record, which is linked to their Meta Account address. There are two options available for setting up the frontend: * One being the automated option where you you run a command that downloads the frontend app from github, install all the dependencies and set up are the required environment varaibles with the required values. * The other option is a manual installtion where you will need to pull down the code from github, install the necessary packages and set up the environment variables. ### Automated Installation In the **Quick Launch Frontend**, select the **"webapp"** template under **Step 3**. <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FvnqpXCodG8yhejp8YlDD%2Fimage.png?alt=media&amp;token=1d2849e5-e48d-4816-a5fc-959e18bc85c6" alt=""><figcaption></figcaption></figure> You’ll see two options for setting up your project. **Option 1: One-liner (Recommended)** provides a bash command that automates the entire setup process: * Clones the frontend project from the Git repository * Installs all required packages * Sets up the necessary environment variables * Launch a dev server To use this option, simply copy the provided bash command and run it in your terminal from the directory where you'd like your project to be created. <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FSzaNifmCbGzE9IO1De0g%2Fimage.png?alt=media&amp;token=c01f4d04-0a8c-4a17-a690-6f782fe90023" alt=""><figcaption></figcaption></figure> Once complete, the development server will automatically start, and you can access your app at <http://localhost:3000> in your browser. ### Manual Installation To manually set up the project, start by cloning the repository: ```bash git clone https://github.com/burnt-labs/xion-user-map-json-store-frontend cd xion-user-map-json-store-frontend ``` Next, create a `.env.local` file in the root of your project directory. #### Set up Environment Variables In the **Quick Launch Frontend**, select the **"webapp"** template: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FQIfMNt7lrs6DaVcxmA92%2Fimage.png?alt=media&amp;token=05d00c56-fc21-4935-948d-2135725e14ef" alt=""><figcaption></figcaption></figure> Under the **"Manual Setup"** section, copy the environment variable values and paste them into your `.env.local` file: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2F9HQSSVhjrYTu0AUWHMvY%2Fimage.png?alt=media&amp;token=828412b4-2ec8-41c8-91e3-16b4d7b44039" alt=""><figcaption></figcaption></figure> Once the environment is configured, install the dependencies and start the local development server: ```bash npm install npm run dev ``` You can now access the app at <http://localhost:3000> in your browser. #### The Frontend Interface After the app loads in your browser, you’ll see the homepage with a **“Connect”** button. Click this button to log in with your Verona Meta Account. <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FujxFol60dJ2ZQS3EkCfS%2Fimage.png?alt=media&amp;token=240c4f45-fd27-4b28-80a8-2144a19b21dd" alt=""><figcaption></figcaption></figure> Once connected, the interface will allow you to: * **Submit JSON data**: Enter a JSON object and click **“Submit JSON”** to trigger a transaction that stores the data in your User Map on-chain. * **Retrieve data**: Use the available menu options to query and view stored JSON data from the smart contract. <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FiAaXrEVHtVaut6uo2mek%2Fimage.png?alt=media&amp;token=b39b292c-69ea-4e37-acef-f6c372ead0b0" alt=""><figcaption></figcaption></figure> *** For a detailed breakdown of the contract’s design, execution messages, and frontend setup see [Full Guide – Building a Per-User Data Storage app](/en/build-on-verona/computation/use-cases/building-a-per-user-data-storage-dapp). # React Native Mobile App in 5 Minutes Building a **Mobile App** on Verona typically involves three main components: * **Smart contract** – Contains the core business logic of your App. * **Treasury contract** – Enables gasless transactions using **Fee Grants**, making onboarding smoother for users. It also handles **Authorization Grants**, which allow your frontend to execute transactions on behalf of the user, enabling a more traditional application experience through our OAuth2-style **Abstraxion** solution. * **Mobile Frontend** – This is your App’s interface, used to display data and trigger transactions via the smart contract. As a beginner to Verona development, getting a fully functional App up and running should be simple and shouldn’t require any complex setup. With this in mind, we’ve created a [**quick launch frontend solution**](https://quickstart.dev.testnet.burnt.com) that handles the creation of both the **User Map** and **Treasury** contracts with the Treasury contract being fully configured. We've also created a fully functional [**React Native Mobile App**](https://github.com/burnt-labs/abstraxion-expo-demo) for interacting with the **User Map** contract. ## What is the User Map App? The **User Map** contract is a lightweight and beginner friendly smart contract designed to help developers, especially those coming from traditional web or application development, understand how to manage per-user data in a decentralized environment. Think of it like a basic key-value store: * **Key:** User's wallet address * **Value:** A JSON object (e.g., user profile, preferences, settings) You can find the source code here: [github.com/burnt-labs/contracts/tree/main/contracts/user\_map](https://github.com/burnt-labs/contracts/tree/main/contracts/user_map). ## Prerequisites Before you begin, ensure you have the following installed and configured: * [**Node.js** (LTS version recommended) and **npm**](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) * An Android Emulator via [Android Studio](https://docs.expo.dev/get-started/set-up-your-environment?platform=android\&device=physical\&mode=development-build\&buildEnv=local#set-up-an-android-device-with-a-development-build), iOS Simulator via [Xcode](https://docs.expo.dev/get-started/set-up-your-environment?platform=ios\&device=physical\&mode=development-build\&buildEnv=local#set-up-an-ios-device-with-a-development-build), **or** a physical mobile device for testing The following [guide](https://docs.expo.dev/guides/local-app-development) will help you set up your local development environment for Expo. We also have a guide in the docs on [Set up your Verona Mobile Development Environment](/en/build-on-verona/accounts/mobile-app/set-up-mobile-development-environment), which shows how to get your Android emulator and iOS simulator set up. ## Create Instance of User Map and Treasury Contracts **Compiling** and **instantiating** smart contracts can feel like huge tasks, especially for new developers. You typically need to set up your development environment with tools like **Docker** and **xiond**, and go through the full process of compiling, deploying, and instantiating your contracts manually. On top of that, creating and configuring a Treasury contract via the [**Dev Portal**](https://dev.testnet.burnt.com) can be overwhelming if you're just getting started. To make this much easier, we’ve created a [**quick launch frontend solution**](https://quickstart.dev.testnet.burnt.com) for this **User Map** App that takes care of all the heavy lifting, so you can skip the setup pain and focus on experimenting with a real, working Mobile app. 1. Go to <https://quickstart.dev.testnet.burnt.com> and log in using your **Meta Account** <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FkLbQrnyLcugWoZH4wXru%2Fimage.png?alt=media&amp;token=0ad0e7f8-1d48-4335-8e53-a5b0f08096fd" alt=""><figcaption></figcaption></figure> 2. Click the **Launch User Map & Fund Treasury** button <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FN3N2ax9gs55WvrUqXBmL%2Fimage.png?alt=media&amp;token=7e51fc45-9839-4a63-9fd2-d8a9bdc9131b" alt=""><figcaption></figcaption></figure> Behind the scenes, this: * Instantiates your **User Map** contract * Deploys a **Treasury contract** with a configured **Fee Grant** to enable gasless transactions and also **Authorization Grants** for users to give the Mobile app approval to interact with the **User Map** contract on their behalf * Funds the **Treasury contract** to pay transaction fees for users via the **Fee Grant** These 4 environment variables will be generated which will you will need to add to the Mobile App `.env.local` environment file: ```env EXPO_PUBLIC_USER_MAP_CONTRACT_ADDRESS="..." EXPO_PUBLIC_TREASURY_CONTRACT_ADDRESS="..." EXPO_PUBLIC_RPC_ENDPOINT="..." EXPO_PUBLIC_REST_ENDPOINT="..." ``` ## Set up the Mobile App The Mobile App will allow users to log in using their Meta Account via multiple authenticators (Email, Social Login, Wallets, Passkeys). Once logged in, users can query contract data and execute transactions to update their User Map record, which is linked to their Meta Account address. To run the mobile app in either the iOS Simulator or Android Emulator, execute the following commands in your terminal: ```bash git clone https://github.com/burnt-labs/abstraxion-expo-demo.git cd abstraxion-expo-demo ``` ### Set up Environment Variables In the **Quick Launch Frontend** click the "**Mobile**" template: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FyKDIosAboqwU7KbPsFFj%2Fimage.png?alt=media&amp;token=15932d2c-b8e2-4395-a715-593facb195b3" alt=""><figcaption></figcaption></figure> There are two options available for copying the variables into your project: * **Option 1: One-liner (Recommended):** Run the bash command provided in your terminal from within your project directory to automatically download and save the environment file into your project with the variables set to the correct values. <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2Frke08E5kycnmNQbZfmx1%2Fimage.png?alt=media&amp;token=e30b69f8-7ece-4a7c-81f1-c1730487968b" alt=""><figcaption></figcaption></figure> * **Manual Setup:** Copy and paste the actual variables into your `.env.local` file in the root of your project: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FgTyR7NlW5eYF2p6h3jhG%2Fimage.png?alt=media&amp;token=e83663fe-8297-4dd3-8208-299485b150d7" alt=""><figcaption></figcaption></figure> Install the dependencies by executing the following: ```bash npm install ``` 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: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FkDxyyGEJUeDW1UzDDtri%2F02%20-%20User%20Map%20Demo%20App.png?alt=media&amp;token=2f179b1b-1c11-49c8-a3a5-23136436d821" alt="" width="375"><figcaption></figcaption></figure> Once logged in you should see something like the following: <figure><img src="https://3630978198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB5Z5ijJgMx0GJO3l1Il9%2Fuploads%2FSKpJIQeCO4UxvmMP95o5%2F01%20-%20User%20Map%20Demo%20App.png?alt=media&amp;token=10082197-a4af-49f6-abee-ece8bbd04467" alt="" width="375"><figcaption></figcaption></figure> # Build a TODO App using the Collection-Document Storage Smart 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 advanced 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 ```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> 1. You will first need to clone the repository: ```bash git clone https://github.com/burnt-labs/todo-app-frontend ``` 2. Install dependencies: ```bash cd todo-app-frontend npm install ``` 3. Copy the **`.env.example`** file and name it **`.env.local`** and set the values with the information below: ```javascript NEXT_PUBLIC_CONTRACT_ADDRESS="xion1svpts9q2ml4ahgc4tuu95w8cqzv988s6mf5mupt5kt56gvdnklks9hzar4" NEXT_PUBLIC_TREASURY_ADDRESS="xion1aza0jdzfc7g0u64k8qcvcxfppll0cjeer56k38vpshe3p26q5kzswpywp9" 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> # Local Development Setting up your local environment is the first step towards developing powerful decentralized applications on Verona. We've created a series of detailed guides to walk you through the process, ensuring a smooth and efficient setup. <table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Set Up Environment</strong></td><td>Configure your Development Environment to significantly streamline your smart contract development.</td><td><a href="/en/build-on-verona/computation/local-development/setting-up-env">Setting up Environment</a></td></tr><tr><td><strong>Deploying Your First Smart Contract</strong></td><td>Walk through the process of deploying and interacting with a smart contract on the <strong>Verona</strong> network.</td><td><a href="/en/build-on-verona/computation/local-development/deploy-a-cosmwasm-smart-contract">Deploying Your First Smart Contract</a></td></tr></tbody></table> # Setting up Environment Guides according to different environments: <table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Local Contract Development Environment on Non-Windows</td><td><a href="/en/build-on-verona/computation/local-development/setting-up-env/installation-prerequisites-setup-local-environment">Setting up your Local Smart Contract Development Environment</a></td></tr><tr><td>Local Contract Development Environment on Windows</td><td><a href="/en/build-on-verona/computation/local-development/setting-up-env/setting-up-your-xion-smart-con
프로젝트로 돌아가기