Movement 백서

Movement

원문

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

testnet.movementnetwork.xyz/' }) const movement = new Movement(config); ``` * Creates a new Movement configuration instance * Connects to the Movement testnet network * Initializes the Movement client with the configuration ## Component Breakdown ### 1️⃣ Hook Usage ```typescript const { account, signAndSubmitTransaction } = useWallet(); ``` * Uses the `useWallet` hook to get: * `account`: Current connected wallet account * `signAndSubmitTransaction`: Function to sign and submit transactions ### 2️⃣ Transaction Handler ```typescript const onSignAndSubmitTransaction = async () => { ``` This function handles: 1. Account verification 2. Transaction creation and submission 3. Transaction confirmation #### Transaction Structure ```typescript { sender: account.address, data: { function: "<address_account>::<module_name>::<function>", functionArguments: [account.address, 1], } } ``` * `sender`: The address of the transaction sender * `function`: Calls the Aptos account transfer function * `functionArguments`: Array containing: * Recipient address (in this case, sending to self) * Amount to transfer (1 unit) ### 3️⃣ Transaction Confirmation ```typescript await movement.waitForTransaction({ transactionHash: response.hash }); ``` * Waits for transaction confirmation on the blockchain * Includes error handling for failed transactions ### 4️⃣ UI Component ```typescript return ( <button onClick={onSignAndSubmitTransaction}> Sign and submit transaction </button> ); ``` * Renders a simple button * Triggers the transaction process when clicked ## Usage Example ```typescript import SignAndSubmit from './components/signAndSubmitTx'; function App() { return ( <div> <SignAndSubmit /> </div> ); } ``` ## Important Notes 1. This component requires a connected wallet to function 2. It's configured to work with Mainnet (production network) 3. The current implementation sends 1 unit to the same address (self-transfer) 4. Error handling is implemented for transaction confirmation 5. The component should be used within a wallet provider context ## Fullcode ```typescript title="src/components/signAndSubmitTx.tsx" import React from 'react'; import { useWallet } from '@aptos-labs/wallet-adapter-react'; import { Movement, MovementConfig, Network } from '@moveindustries/ts-sdk'; const config = new MovementConfig({ network: Network.MAINNET }); const movement = new Movement(config); const SignAndSubmit = () => { const { account, signAndSubmitTransaction } = useWallet(); const onSignAndSubmitTransaction = async () => { if(account == null) { throw new Error("Unable to find account to sign transaction") } const response = await signAndSubmitTransaction({ sender: account.address, data: { function: "0x1::aptos_account::transfer", functionArguments: [account.address, 1], }, }); // if you want to wait for transaction try { await movement.waitForTransaction({ transactionHash: response.hash }); } catch (error) { console.error(error); } }; return ( <button onClick={onSignAndSubmitTransaction}> Sign and submit transaction </button> ); }; export default SignAndSubmit; ``` # Sign and Verify Message URL: /devs/interactonchain/wallet-adapter/useWallet/signMessage ## Overview This React component creates a user interface for signing and verifying messages using an Movement wallet. It's commonly used in blockchain applications to prove ownership of a wallet address by signing messages. ## Key Features 1. Message signing 2. Message verification 3. Wallet connection status 4. Error handling ## How It Works ### 1️⃣ Component Setup ```typescript const { signMessage, signMessageAndVerify, connected, account } = useWallet(); ``` * Uses the Aptos wallet adapter to get necessary functions and wallet status * `connected`: Tells if wallet is connected * `account`: Contains wallet information ### 2️⃣ State Management ```typescript const [message, setMessage] = useState<string>(''); const [nonce, setNonce] = useState<string>(''); const [signedMessage, setSignedMessage] = useState<any>(null); const [verificationResult, setVerificationResult] = useState<boolean | null>(null); const [error, setError] = useState<string | null>(null); ``` Manages five different states: * `message`: The text message to be signed * `nonce`: A random string to prevent replay attacks * `signedMessage`: Stores the signed message response * `verificationResult`: Stores whether the message verification was successful * `error`: Stores any error messages ### 3️⃣ Message Signing Function ```typescript const handleSignMessage = async () => { setError(null); try { const response = await signMessage({ message, nonce }); setSignedMessage(response); } catch (err: any) { setError(`Failed to sign message: ${err.message}`); } }; ``` * Clears any previous errors * Attempts to sign the message using the wallet * Stores the signed message or captures any errors ### 4️⃣ Message Verification Function ```typescript const handleVerifyMessage = async () => { setError(null); try { const result = await signMessageAndVerify({ message, nonce }); setVerificationResult(result); } catch (err: any) { setError(`Failed to verify message: ${err.message}`); } }; ``` * Clears any previous errors * Verifies the signed message * Stores the verification result or captures any errors ### 5️⃣ User Interface The component renders different UI elements based on wallet connection status: If wallet is not connected: * Shows a message asking user to connect wallet If wallet is connected: 1. Shows the connected wallet address 2. Provides a text area for entering the message 3. Provides an input field for the nonce 4. Shows a "Sign Message" button 5. If message is signed: * Displays the signed message * Shows a "Verify Message" button 6. Shows verification result if available 7. Displays any errors that occur ## Use Cases 1. **Identity Verification**: Prove ownership of a wallet address 2. **Authentication**: Can be used as part of a login system 3. **Message Authentication**: Ensure messages are authentic and haven't been tampered with ## Error Handling * Handles signing errors * Handles verification errors * Displays user-friendly error messages This component provides a complete solution for signing and verifying messages using an Aptos wallet, with a user-friendly interface and proper error handling. ## Code Example ```typescript title="signAndVerify" import React, { useState } from 'react'; import { useWallet } from '@aptos-labs/wallet-adapter-react'; const SignMessageDemo = () => { const { signMessage, signMessageAndVerify, connected, account } = useWallet(); const [message, setMessage] = useState<string>(''); const [nonce, setNonce] = useState<string>(''); const [signedMessage, setSignedMessage] = useState<any>(null); const [verificationResult, setVerificationResult] = useState<boolean | null>(null); const [error, setError] = useState<string | null>(null); const handleSignMessage = async () => { setError(null); try { const response = await signMessage({ message, nonce }); setSignedMessage(response); } catch (err: any) { setError(`Failed to sign message: ${err.message}`); } }; const handleVerifyMessage = async () => { setError(null); try { const result = await signMessageAndVerify({ message, nonce }); setVerificationResult(result); } catch (err: any) { setError(`Failed to verify message: ${err.message}`); } }; return ( <div> <h1>Aptos Sign and Verify Message</h1> <div> {connected ? ( <div> <p>Connected to: {account?.address}</p> <div className="flex flex-col gap-4"> <textarea value={message} onChange={(e) => setMessage(e.target.value)} placeholder="Enter your message here" className="border rounded p-2" /> <input type="text" value={nonce} onChange={(e) => setNonce(e.target.value)} placeholder="Enter nonce (random string) here" className="border rounded p-2 mt-2" /> <button onClick={handleSignMessage} className="bg-blue-500 text-white rounded p-2 mt-2"> Sign Message </button> {signedMessage && ( <div> <h4>Signed Message</h4> <pre>{JSON.stringify(signedMessage, null, 2)}</pre> <button onClick={handleVerifyMessage} className="bg-green-500 text-white rounded p-2 mt-2"> Verify Message </button> </div> )} {verificationResult !== null && ( <div> <h4>Verification Result</h4> <p>{verificationResult ? 'Message is verified!' : 'Failed to verify message.'}</p> </div> )} {error && ( <div className="text-red-600"> <p>{error}</p> </div> )} </div> </div> ) : ( <p>Please connect your wallet to sign and verify messages.</p> )} </div> </div> ); }; export default SignMessageDemo; ``` ## Sign & Submit BCS Transaction How to sign and submit a BCS (Binary Canonical Serialization) transaction on the MoveVM blockchain. It specifically shows how to transfer tokens using the Move account module. ## Function Breakdown ### Transaction Submission Function ```typescript const onSignAndSubmitBCSTransaction = async () => { const response = await signAndSubmitTransaction({ sender: account.address, data: { function: "0x1::aptos_account::transfer", functionArguments: [AccountAddress.from(account.address), new U64(1)], }, }); // ... transaction confirmation ... }; ``` #### Key Components: 1. **Sender**: The address of the account initiating the transaction 2. **Function Path**: `0x1::aptos_account::transfer` * `0x1`: Core framework address * `aptos_account`: Module name * `transfer`: Function name 3. **Function Arguments**: * `AccountAddress.from(account.address)`: Recipient address * `new U64(1)`: Amount to transfer (1 unit) ### Transaction Confirmation ```typescript try { await aptos.waitForTransaction({ transactionHash: response.hash }); } catch (error) { console.error(error); } ``` * Waits for transaction confirmation * Handles any errors during confirmation process ### UI Element ```typescript <button onClick={onSignAndSubmitTransaction}> Sign and submit BCS transaction </button> ``` * Simple button to trigger the transaction ## Important Notes 1. **BCS Format**: Uses Binary Canonical Serialization for efficient transaction encoding 2. **Error Handling**: Includes basic error handling for transaction confirmation 3. **Amount**: Example shows transfer of 1 unit (adjust as needed) 4. **Gas Fees**: Transaction will require gas fees (not shown in example) ## Common Use Cases 1. Token transfers 2. Smart contract interactions 3. Blockchain state modifications # Requirements URL: /general/nodes/archival-node/run To ensure that your archival fullnode operates smoothly, it should meet the requirements specified in this document. ## Hardware requirements <Callout type="warning"> **Minimum hardware requirements** Failing to meet the minimum hardware requirements means that your archival node will experience degradation under load and general instability in production environments. Archival nodes have higher requirements than standard PFNs due to the complete blockchain history they maintain. </Callout> For running a production-grade archival node, we recommend: | Resource | Minimum | Recommended | | -------- | ------------ | ------------- | | Storage | 1TB NVMe SSD | 2TB+ NVMe SSD | | Memory | 16GB RAM | 32GB RAM | | CPU | 8 cores | 16 cores | | Network | 100 Mbps | 1 Gbps | <Callout type="info"> **Storage growth** Archival nodes store the complete blockchain history and will continue to grow over time. As of January 2026: * Mainnet: \~700GB * Testnet: \~260GB Plan for storage expansion as the blockchain grows. </Callout> ## Network requirements and ports When running an archival node, you need to open network ports to allow other nodes (peers) to connect. The public network is used for PFNs to connect to other PFNs and VFNs. ### Port settings The recommendations below assume default port settings. If you have changed the default port settings in your configuration file, adjust accordingly. <Callout type="warning"> **Exposing ports** Unless explicitly required, we recommend that you do not expose any other ports while operating an archival node. Exposing additional ports can increase the attack surface of your node. </Callout> #### Running an archival node: Assuming default ports are used, configure the following: * Open the following TCP ports: * `6182` – **Public network**: Open this port publicly to enable other PFNs to connect to your node. * Close the following TCP ports: * `9101` – **Inspection service**: Close this port to prevent unauthorized metric inspection. * `9102` – **Admin service**: Close this port to prevent unauthorized admin service interaction. * `80/8080` - **REST API**: Close this port to prevent unauthorized REST API access. <Callout type="warning"> **Exposing services** The inspection service port (`9101`), admin service port (`9102`) and the REST API port (`80` or `8080`) are useful for your internal network (e.g., application development and debugging). However, the inspection service port and the admin service port should never be exposed publicly. If you expose the REST API endpoint publicly, deploy additional authentication or rate-limiting to prevent abuse. </Callout> ## Storage requirements Archival nodes store the entire history of the blockchain, so the database size will continue to grow unbounded. Unlike standard PFNs that prune old data, archival nodes maintain complete ledger history from genesis. Current storage estimates: * **Mainnet**: \~700GB (and growing) * **Testnet**: \~260GB (and growing) We recommend using NVMe SSDs for optimal performance due to the high I/O requirements of archival nodes. ## Software requirements You will need one of the following: * **Docker** (recommended for most users) * **Rust toolchain** (for building from source) Additionally, to bootstrap your archival node from Move Industries' public backups, you will need: * **restic** backup tool ([installation instructions](https://restic.net/)) ## Bootstrapping from backups Move Industries provides public backups of archival node data that are updated hourly. This is the fastest way to bootstrap an archival node rather than syncing from genesis. Download and use the restore script from the Movement Networks repository: ```shellscript filename="Terminal" # Download the restore script curl -O https://raw.githubusercontent.com/movement-network/movement-networks/main/l1_restore.sh chmod +x l1_restore.sh # Restore mainnet data ./l1_restore.sh mainnet ./data # Or restore testnet data ./l1_restore.sh testnet ./data ``` The script handles all the restic configuration for anonymous access to the public S3 backup buckets. <Callout type="info"> **Backup schedule** * **Frequency**: Hourly snapshots * **Retention**: 14 days of snapshots * **Format**: restic backup repositories </Callout> # Verify an Archival Node URL: /general/nodes/archival-node/run/verify After deploying your archival node, verify that it's running correctly and can access historical data. ## Basic Health Check Check that the node is responding and syncing: ```shellscript filename="Terminal" # Check node health curl http://localhost:8080/v1 # Expected output includes: # - chain_id # - epoch # - ledger_version # - oldest_ledger_version # - ledger_timestamp_usec # - node_role # - oldest_block_height # - block_height # - git_hash ``` ## Verify Sync Status Check the current ledger version and compare it to the network: ```shellscript filename="Terminal" # Get your node's ledger version curl -s http://localhost:8080/v1 | jq '.ledger_version' # Compare with public endpoint # For mainnet: curl -s https://mainnet.movementnetwork.xyz/v1 | jq '.ledger_version' # For testnet: curl -s https://testnet.movementnetwork.xyz/v1 | jq '.ledger_version' ``` Your node's ledger version should be close to (or equal to) the public endpoint's version. ## Verify Historical Data Access The key difference between an archival node and a standard PFN is the ability to query historical data. Verify this by querying early transactions: ```shellscript filename="Terminal" # Query transaction at version 1 (genesis) curl http://localhost:8080/v1/transactions/by_version/1 # Query an early block curl http://localhost:8080/v1/blocks/by_height/1 # Query transactions from an early block curl http://localhost:8080/v1/transactions?start=1&limit=10 ``` <Callout type="info"> **Archival Verification** If these historical queries return data successfully, your archival node is correctly maintaining full history. A standard PFN would return errors for very old data that has been pruned. </Callout> ## Check Oldest Ledger Version Verify that your node has data from the beginning: ```shellscript filename="Terminal" curl -s http://localhost:8080/v1 | jq '.oldest_ledger_version' ``` For an archival node, `oldest_ledger_version` should be `"0"` or a very low number, indicating data from genesis is available. ## Verify Pruning is Disabled Check the node logs to confirm pruning is disabled: ```shellscript filename="Terminal" # For Docker docker logs aptos-archival-node 2>&1 | grep -i "pruner" # Look for messages indicating pruning is disabled ``` ## Monitor Node Metrics The node exposes Prometheus metrics on port 9101: ```shellscript filename="Terminal" # Check metrics endpoint curl http://localhost:9101/metrics # Key metrics to monitor: # - aptos_state_sync_version (current synced version) # - aptos_storage_ledger_version (ledger version in storage) # - aptos_storage_oldest_ledger_version (oldest available version) ``` ## Common Issues ### Node is behind the network If your node's ledger version is significantly behind: 1. Check network connectivity to upstream peers 2. Verify port 6182 is open for outbound connections 3. Check available disk space 4. Review logs for errors ### Historical queries fail If queries for old data fail: 1. Verify `storage_pruner_config.ledger_pruner_config.enable` is `false` in your config 2. Ensure you restored from a complete archival backup 3. Check that the restore completed successfully ### High disk usage Archival nodes require significant storage: 1. Monitor disk usage trends 2. Plan for storage expansion 3. Consider using NVMe SSDs for better performance ## Troubleshooting ### Check logs ```shellscript filename="Terminal" # Docker docker logs aptos-archival-node --tail 100 # Source build # Logs are typically written to stdout/stderr ``` ### Restart the node ```shellscript filename="Terminal" # Docker docker restart aptos-archival-node # Source build # Stop and restart the process ``` ### Verify configuration Ensure your `archival-fullnode.yaml` has the correct settings: ```yaml storage: storage_pruner_config: ledger_pruner_config: enable: false # Must be false for archival ``` # Requirements URL: /general/nodes/full-node/run To ensure that your public fullnode (PFN) operates smoothly, it should meet the requirements specified in this document. ## Hardware requirements <Callout type="warning"> **Minimum hardware requirements**<br /> Failing to meet the minimum hardware requirements mean that your PFN will experience degradation under load and general instability in production environments. It is not recommended to run a PFN without meeting the minimum hardware requirements. </Callout> For running a production-grade PFN, we recommend that your hardware meet the same requirements as a validator or VFN. You can see the hardware requirements for these, here: [validator and VFN hardware requirements](/network/nodes/validator-node/node-requirements#hardware-requirements). <Callout type="info"> **Testing PFNs**<br /> If you wish to run a PFN for development or testing only, lower hardware specs can be used. But, it should not be used in production. </Callout> ## Network requirements and ports When you are running a PFN, you are required to open network ports on your nodes to allow other
프로젝트로 돌아가기