Movement 백서

Movement

원문

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

# Movement Network Documentation — Full Text > Full text of every documentation page, concatenated for LLMs and AI tools. - Concise index: https://docs.movementnetwork.xyz/llms.txt - Movement main site index: https://movementnetwork.xyz/llms.txt --- # API Documentation URL: /api # Movement Node API The Movement Full Node API is a RESTful API for client applications to interact with the Movement blockchain. Use this section of the documentation to review all requests that can be made to the full node. ## Contact **Move Industries:** URL: [https://github.com/movement-network/movement](https://github.com/movement-network/movement) ## License Apache 2.0 # FAQ URL: /devs/faq # FAQ Frequently asked questions about working with Movement as a developer. ## What is Movement Network? Movement Network makes the Move programming language accessible to all via our Layer 1 Move Blockchain. ## Is Mainnet/Testnet live? Currently we are live on mainnet and the latest information on networks can be found [here](/devs/networkEndpoints). ## How do I get started building? Our [developer documentation](/devs) will help you through finding exactly what you need in order to start building on Movement. ## How can I get help? Make sure to join our [Discord](https://discord.com/invite/moveindustries) and get yourself a developer role. You can ask any questions you have in dev-chat where someone in the community or our Developer Relations team will be able to answer your questions. ## What are the hardware requirements for running a node? For running a Movement follower node, we recommend: * CPU: 16 cores * RAM: 64GB * Storage: 4TB NVMe SSD * Network: 2.5Gbps However, minimum requirements are 8 cores, 32GB RAM, and 2TB storage. ## What programming languages are supported on Movement? Movement supports the Move programming language. ## How does Movement ensure security? Movement implements multiple security measures: * Secure Move VM implementation * Regular security audits * Strong consensus mechanism * Robust validator network ## What tools are available for developers? Movement provides a comprehensive suite of developer tools: * Movement CLI * SDK support for multiple languages * Development frameworks * Testing environments * Block explorers * Documentation and tutorials # Your First Move Contract URL: /devs/firstMoveContract Welcome to your first journey in deploying a Move module (smart contract) on the Movement Testnet. In the Move programming language, smart contracts are referred to as **modules**. This guide will walk you through each step, ensuring a smooth experience from setup to deployment. ## Prerequisites Before we begin, ensure you have one of the following command-line interfaces (CLIs) installed: * **Movement CLI**: [Installation Guide](/devs/movementcli) * **Aptos CLI**: [Installation Guide](https://aptos.dev/en/build/cli#-install-the-aptos-cli) <Callout type="info"> **First Time Users:** If this is your first time following this tutorial, we recommend using the **Movement CLI testnet build** for the best experience. The Movement CLI is specifically configured for Movement networks and will make the setup process smoother. </Callout> This tutorial uses the **Movement CLI**, but the commands are identical for the Aptos CLI—just replace `movement` with `aptos` in the commands. If you're using the Aptos CLI, you'll need to configure it for a custom network during the initialization process. *** ## Step 1: Scaffold the Project First, let's set up the structure for your Move module. ### Create Your Project Directory Open your command prompt or terminal, create a new directory for your project, and navigate into it: ```bash mkdir hello_blockchain cd hello_blockchain ``` ### Initialize the Move Project Now that you are inside your project directory, run the following command to initialize the Move project structure: ```bash movement move init --name hello_blockchain ``` This command creates the necessary folders and files for your Move project: ``` Move.toml sources/ scripts/ tests/ ``` * **Move.toml**: Configuration file for your Move project. * **sources/**: Directory where you'll write your Move modules. * **scripts/**: Directory for transaction scripts (optional). * **tests/**: Directory for writing unit tests. *** ## Step 2: Initialize the CLI If you are using Aptos CLI - ensure that you are using version 3.5 or lower. You can replace all `movement` commands with `aptos` in the following steps. Now, initialize the CLI with the following command: ```bash movement init ``` <Callout type="info"> **Alternative:** You can also use the following command to skip the interactive prompts: ```bash movement init --network custom --rest-url https://testnet.movementnetwork.xyz/v1 --faucet-url https://faucet.testnet.movementnetwork.xyz/ ``` </Callout> ### CLI Prompts 1. **Choose Network** You'll be prompted to select a network: ```bash Choose network from [devnet, testnet, local, custom | defaults to devnet]: ``` Type `custom` and press **Enter**. You will be promted for the following details from our [Network EndPoints](/devs/networkEndpoints) * RPC/Rest Endpoint: [https://testnet.movementnetwork.xyz/v1](https://testnet.movementnetwork.xyz/v1) * Faucet Endpoint: [https://faucet.testnet.movementnetwork.xyz/](https://faucet.testnet.movementnetwork.xyz/) 1. **Enter Private Key** Next, you'll be asked to enter your private key: ```bash Enter your private key as a hex literal (0x...) [Current: None | No input: Generate new key (or keep one if present)]: ``` * If you have an existing private key, enter it now. * If not, simply press **Enter** to generate a new one. ### Initialization Success After completing the prompts, you should see a message like: ```bash Movement CLI is now set up for account 0xYOUR_ACCOUNT_ADDRESS as profile default! See the account here: https://explorer.movementnetwork.xyz/account/0xYOUR_ACCOUNT_ADDRESS?network=bardock+testnet Run `movement --help` for more information about commands { "Result": "Success" } ``` <Callout type="info"> Note that Bardock Explorer is available here: [https://explorer.movementnetwork.xyz/?network=bardock+testnet](https://explorer.movementnetwork.xyz/?network=bardock+testnet) </Callout> *** ## Step 3: Fund Your Account (If Needed) ## Step 2: Fund Your Account Your account should already be funded with testnet tokens after initialization. However, if you need additional funds for your wallet, you can use the faucet. 1. **Copy Your Account Address** Make note of your account address from the initialization success message (e.g., `0xYOUR_ACCOUNT_ADDRESS`). 2. **Visit the Faucet (Optional)** If you need additional testnet tokens, go to the [Movement Web Faucet](https://faucet.movementnetwork.xyz/) to fund your account. 3. **Request Tokens** Paste your account address into the faucet and request testnet tokens. *** ## Step 4: Explore the Configuration Your project directory now contains a hidden `.movement` folder with a `config.yaml` file: ``` .movement/ └── config.yaml ``` This configuration file stores information about your default profile, including your private key and network settings. ```yaml --- profiles: default: network: Testnet private_key: "YOUR_PRIVATE_KEY" public_key: "YOUR_PUBLIC_KEY" account: "YOUR_ACCOUNT_ADDRESS" rest_url: "https://testnet.movementnetwork.xyz/v1" faucet_url: "https://faucet.testnet.movementnetwork.xyz/" ``` <Callout type="warning"> **Warning:** **Do not commit `config.yaml` to version control systems like GitHub, as it contains your private key!** </Callout> *** ## Step 5: Write Your First Module ### Create the Module File Navigate to the `Sources/` directory and create a new file named `hello_blockchain.move`: ```bash cd Sources touch hello_blockchain.move ``` ### Add the Module Code Open `hello_blockchain.move` in your preferred text editor and paste the following code: ```move module hello_blockchain::message { use std::error; use std::signer; use std::string::{String}; use aptos_framework::account; use aptos_framework::event; struct MessageHolder has key { message: String, message_change_events: event::EventHandle<MessageChangeEvent>, } struct MessageChangeEvent has drop, store { from_message: String, to_message: String, } /// Error code indicating no message is present. const ENO_MESSAGE: u64 = 0; #[view] public fun signature(): address { @hello_blockchain } #[view] public fun get_message(addr: address): String acquires MessageHolder { assert!(exists<MessageHolder>(addr), error::not_found(ENO_MESSAGE)); borrow_global<MessageHolder>(addr).message } public entry fun set_message(account: signer, message: String) acquires MessageHolder { let account_addr = signer::address_of(&account); if (!exists<MessageHolder>(account_addr)) { move_to(&account, MessageHolder { message, message_change_events: account::new_event_handle<MessageChangeEvent>(&account), }); } else { let message_holder = borrow_global_mut<MessageHolder>(account_addr); let from_message = message_holder.message; event::emit_event(&mut message_holder.message_change_events, MessageChangeEvent { from_message, to_message: copy message, }); message_holder.message = message; } } #[test(account = @0x1)] public entry fun sender_can_set_message(account: signer) acquires MessageHolder { let addr = signer::address_of(&account); aptos_framework::account::create_account_for_test(addr); set_message(account, std::string::utf8(b"Hello, Blockchain")); assert!( get_message(addr) == std::string::utf8(b"Hello, Blockchain"), ENO_MESSAGE ); } #[test] public fun signature_okay() { assert!(signature() == @hello_blockchain, ENO_MESSAGE); } } ``` <Callout type="info"> This is a "Hello, Blockchain" module written in Move. We won't dive into the syntax and functionality in this tutorial. </Callout> *** ## Step 6: Compile the Module Let's compile your module to ensure everything is set up correctly. ### Option 1: Without Editing `Move.toml` If you haven't modified the `Move.toml` file, run: ```bash movement move compile --named-addresses hello_blockchain=default ``` ### Option 2: By Editing `Move.toml` To simplify future commands, you can add your account address to `Move.toml`. 1. **Open `Move.toml`** and add: ```toml [addresses] hello_blockchain = "0xYOUR_ACCOUNT_ADDRESS" ``` 2. **Compile without Extra Flags** Now, you can compile with: ```bash movement move compile ``` ### Expected Output If the compilation is successful, you'll see something like: ```json { "Result": [ "a345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a::message" ] } ``` *** ## Step 7: Test the Module Your module includes unit tests. Let's run them to ensure everything works as expected. ### Run Tests ```bash movement move test ``` > **Note:** If you didn't edit `Move.toml`, add the `--named-addresses` flag: ```bash movement move test --named-addresses hello_blockchain=default ``` ### Expected Output You should see output similar to: ``` Running Move unit tests [ PASS ] 0x4bb138fa05ea42faa44268b30872ed6e5a84f25f8718bcac981a6de36a090e3a::message::sender_can_set_message [ PASS ] 0x4bb138fa05ea42faa44268b30872ed6e5a84f25f8718bcac981a6de36a090e3a::message::signature_okay Test result: OK. Total tests: 2; passed: 2; failed: 0 { "Result": "Success" } ``` *** ## Step 8: Publish the Module Now it's time to deploy your module to the Movement Testnet. ### Publish Command If you edited `Move.toml`: ```bash movement move publish ``` If you didn't edit `Move.toml`: ```bash movement move publish --named-addresses hello_blockchain=default ``` ### Optimizing Package Size (Optional) To reduce gas costs and package size, you can publish without including artifacts: ```bash movement move publish --named-addresses hello_blockchain=default --included-artifacts none ``` The `--included-artifacts` option controls what gets included in your package: * **`none`**: Most compact, includes only bytecode (lowest gas cost) * **`sparse`**: Minimal artifacts needed to reconstruct source (default, \~2x size of `none`) * **`all`**: All available artifacts (\~3-4x size of `none`) Using `none` significantly reduces deployment costs but means you cannot reconstruct the source package from the blockchain. This option is particularly useful for deployment of smart contracts without deploying the entire codebase. ### Confirm Deployment Cost You'll be prompted to confirm the transaction and spend a small amount of testnet tokens: ``` Do you want to submit this transaction? [Y/n] ``` Type `Y` and press **Enter**. > **Ensure you have sufficient testnet tokens from the faucet before proceeding.** ### Expected Output Upon successful deployment, you'll receive a confirmation: ``` Transaction submitted: https://explorer.movementnetwork.xyz/txn/0xTRANSACTION_HASH?network=bardock+testnet { "Result": { "transaction_hash": "0xTRANSACTION_HASH", "gas_used": 1696, "gas_unit_price": 100, "sender": "0xYOUR_ACCOUNT_ADDRESS", "sequence_number": 0, "success": true, "timestamp_us": 1726483247259754, "version": 183468408, "vm_status": "Executed successfully" } } ``` *** ## Step 9: Interact with Your Contract Congratulations! You've successfully deployed your first Move module on the Movement Testnet. * **View Your Module**: Visit the provided transaction link to see details on the explorer. * **Interact**: Use the Movement CLI or write scripts to interact with your deployed module. *** ## Recap In this tutorial, you've: * Scaffolded a new Move project. * Initialized the Movement CLI. * Funded your testnet account. * Written and compiled a Move module. * Ran unit tests to ensure functionality. * Deployed your module to the testnet. *** We're excited to see you continue on journey into the Move language! **Happy coding!** # Developer Documentation URL: /devs <Cards> <MovementCard href="/devs/firstMoveContract" title="Your First Move"> Build your first Move Module </MovementCard> <MovementCard href="/devs/movementcli" title="Movement CLI"> Install and use the Movement CLI </MovementCard> <MovementCard href="/devs/interactonchain/tsSdk" title="Interact with your Move Modules"> Start building apps on the Movement Network </MovementCard> <MovementCard href="/devs/networkEndpoints" title="Network Endpoints"> All the endpoints you need to get started </MovementCard> <MovementCard href="https://faucet.movementnetwork.xyz/" title="Faucet"> Get Testnet tokens </MovementCard> <MovementCard href="https://explorer.movementnetwork.xyz/" title="Explorer"> Our Block Explorer </MovementCard> </Cards> # Indexer URL: /devs/indexing The Movement Indexer is a GraphQL API you can use to retrive aggregate data, historical data, and data that might be hard to get from the simpler full node API. | Service | URL | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | API Explorer (testnet) | [https://cloud.hasura.io/public/graphiql?endpoint=https://indexer.testnet.movementnetwork.xyz/v1/graphql](https://cloud.hasura.io/public/graphiql?endpoint=https://indexer.testnet.movementnetwork.xyz/v1/graphql) | | GraphQl Endpoint (testnet) | [https://indexer.testnet.movementnetwork.xyz/v1/graphql](https://indexer.testnet.movementnetwork.xyz/v1/graphql) | | API Explorer (mainnet) | [https://cloud.hasura.io/public/graphiql?endpoint=https://indexer.mainnet.movementnetwork.xyz/v1/graphql](https://cloud.hasura.io/public/graphiql?endpoint=https://indexer.mainnet.movementnetwork.xyz/v1/graphql) | | GraphQl Endpoint (mainnet) | [https://indexer.mainnet.movementnetwork.xyz/v1/graphql](https://indexer.mainnet.movementnetwork.xyz/v1/graphql) | ## Third Party Indexers | Service | URL | | ------- | -------------------------------------------------------------------------------------------------------- | | Sentio | [https://rpc.sentio.xyz/movement-indexer/v1/graphql](https://rpc.sentio.xyz/movement-indexer/v1/graphql) | ## Architecture There are three main components to indexing with the Movement Network. We first have the Movement full node which provides a gRPC stream of transactions. The gRPC stream of transactions is consumed by the Transaction Streaming Service which includes the following components: * [**Cache Worker**](https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/indexer-grpc/indexer-grpc-cache-worker): Pulls transactions from the node and stores them in Redis. * [**File Store**](https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/indexer-grpc/indexer-grpc-file-store): Fetches transactions from Redis and stores them in a filesystem. * [**Indexer API**](https://github.com/aptos-labs/aptos-indexer-processors): Consumes the data-service providing a GraphQL API to dApps and other clients wishing to query the network. The Indexer API also allows the development of customized processors. ## Running the Transaction Streaming Service The following guides from Aptos are provided: [Aptos Documentation](https://aptos.dev/en/build/indexer/txn-stream/local-development) ## Indexing Movement - Future Plans Move Industries plans to provide a hosted Transaction Stream Service in the near future. In the meantime, anyone wishing to index the Movement network would need to self-host their own Transaction Streaming Service. ## Providing a GraphQL API With the Data Service running, the Indexer API can be configured to consume it as per the following [repository](https://github.com/aptos-labs/aptos-indexer-processors/) to provide a GraphQL API to downstream clients: [**Data Service**](https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/indexer-grpc/indexer-grpc-data-service): Serves transactions via a gRPC stream to downstream clients. It pulls from either the cache or the file store depending on the age of the transaction. ## Example Queries ### NFT Queries #### 1. Get all NFTs owned by an address with their collection info ``` query GetUserNFTs { current_token_ownerships_v2( where: { owner_address: {_eq: "0x123..."}, amount: {_gt: 0} } ) { token_data_id amount current_token_data: current_token_data { token_name token_uri token_properties collection_id current_collection: current_collection { collection_name creator_address description uri } } } } ``` #### 2. Get Recent NFT Sales/Transfers with Price Info ``` query GetRecentNFTSales { token_activities_v2( where: { type: {_in: ["0x3::token::DepositEvent", "0x3::token::WithdrawEvent"]} }, order_by: {transaction_timestamp: desc}, limit: 50 ) { transaction_version transaction_timestamp from_address to_address token_amount current_token_data { token_name collection_id current_collection { collection_name } } } } ``` #### 3. Get Collection Statistics ``` query GetCollectionStats { current_collections_v2( where: { collection_id: {_eq: "0x123..."} } ) { collection_name creator_address current_supply max_supply description uri # Get ownership distribution current_token_ownerships_v2_aggregate( where: { amount: {_gt: 0} } ) { aggregate { count(distinct: true) } } } } ``` ### DeFi Queries #### 1. Get User's Token Balances ``` query GetUserTokenBalances { current_fungible_asset_balances( where: { owner_address: {_eq: "0x123..."}, amount: {_gt: 0} } ) { asset_type amount last_transaction_timestamp metadata } } ``` #### 2. Track Large Token Transfers ``` query GetLargeTokenTransfers { fungible_asset_activities( where: { amount: {_gt: "1000000000"}, # Adjust threshold as needed type: {_in: ["0x1::coin::WithdrawEvent", "0x1::coin::DepositEvent"]} }, order_by: {transaction_timestamp: desc}, limit: 100 ) {
프로젝트로 돌아가기