### Install LayerZero Solidity Examples SDK Source: https://build.avax.network/integrations/layerzero Installs the LayerZero SDK for Solidity, providing examples and base contracts for building omnichain applications. This is typically the first step for Solidity developers getting started with LayerZero. ```shell npm install @layerzerolabs/solidity-examples ``` -------------------------------- ### Installation & Setup Source: https://build.avax.network/llms-full Instructions for installing and setting up the Avalanche SDK client. ```APIDOC ## Installation & Setup For setup instructions, see the [Getting Started](/avalanche-sdk/client-sdk/getting-started) guide. ```typescript import { createAvalancheClient } from "@avalanche-sdk/client"; import { avalanche } from "@avalanche-sdk/client/chains"; const client = createAvalancheClient({ chain: avalanche, transport: { type: "http" }, }); ``` ``` -------------------------------- ### C-Chain Client: Installation and Setup (TypeScript) Source: https://build.avax.network/llms-full Provides code examples for setting up the C-Chain client using the Avalanche SDK. It demonstrates both creating a full Avalanche client and then accessing the C-Chain, as well as creating a standalone C-Chain client instance. ```typescript import { createAvalancheClient } from "@avalanche-sdk/client"; import { avalanche } from "@avalanche-sdk/client/chains"; const client = createAvalancheClient({ chain: avalanche, transport: { type: "http" }, }); const cChainClient = client.cChain; // Or create a standalone C-Chain client: import { createCChainClient } from "@avalanche-sdk/client"; const cChainClientStandalone = createCChainClient({ chain: avalanche, transport: { type: "http" }, }); ``` -------------------------------- ### Install Ramp SDK for Web Applications Source: https://build.avax.network/integrations/ramp-network This command installs the Ramp Instant SDK for web applications using npm. This is the first step to integrating Ramp into your project. ```bash npm install @ramp-network/ramp-instant-sdk ``` -------------------------------- ### Initialize SDK Client for Avalanche (TypeScript) Source: https://build.avax.network/llms-full Shows a simple and focused example of initializing an SDK client for an integration on the Avalanche network. It includes essential parameters like API key and network specification, suitable for getting started. ```typescript // ✅ Good - Clear and focused import { YourSDK } from 'your-sdk'; const client = new YourSDK({ apiKey: process.env.API_KEY, network: 'avalanche' }); const result = await client.query({ /* ... */ }); ``` ```typescript // ❌ Bad - Too complex for getting started // Multiple files, complex error handling, etc. ``` -------------------------------- ### Install Sherry SDK with npm or yarn Source: https://build.avax.network/integrations/sherry-protocol This snippet shows how to install the Sherry SDK using either npm or yarn package managers. This is the first step to start building with Sherry. ```bash npm install @sherrylinks/sdk ``` ```bash yarn add @sherrylinks/sdk ``` -------------------------------- ### Start Local Avalanche Node Validator Source: https://build.avax.network/llms-full The 'avalanche node local start' command (ALPHA) sets up a validator on a local server, validating the Avalanche Primary Network and a chosen subnet. It typically runs an interactive wizard to guide through setup. After completion, bootstrapping on the primary network must finish before further commands can be run. Use 'avalanche node status local' to check bootstrapping status. ```bash avalanche node local start [subcommand] [flags] ``` -------------------------------- ### Download and Unzip Pre-Built Binaries Source: https://build.avax.network/llms-full Instructions for downloading and unzipping the AvalancheGo binary for different operating systems. ```APIDOC ## Download and Unzip Binary ### MacOS 1. Download `avalanchego-macos-.zip` from the [AvalancheGo releases page](https://github.com/ava-labs/avalanchego/releases). 2. Unzip the file: ```bash unzip avalanchego-macos-.zip ``` This will create a folder named `avalanchego-` containing the binaries. ### Linux (amd64) 1. Download `avalanchego-linux-amd64-.tar.gz` from the [AvalancheGo releases page](https://github.com/ava-labs/avalanchego/releases). 2. Unzip the file: ```bash tar -xvf avalanchego-linux-amd64-.tar.gz ``` This will create a folder named `avalanchego--linux` containing the binaries. ### Linux (Arm64) 1. Download `avalanchego-linux-arm64-.tar.gz` from the [AvalancheGo releases page](https://github.com/ava-labs/avalanchego/releases). 2. Unzip the file: ```bash tar -xvf avalanchego-linux-arm64-.tar.gz ``` This will create a folder named `avalanchego--linux` containing the binaries. ``` -------------------------------- ### Validator Example (Bytes) Source: https://build.avax.network/llms-full An example demonstrating the byte representation of a Validator. It shows the serialization of NodeID, Start, End, and Wght. ```text [ // node id 0xaa, 0x18, 0xd3, 0x99, 0x1c, 0xf6, 0x37, 0xaa, 0x6c, 0x16, 0x2f, 0x5e, 0x95, 0xcf, 0x16, 0x3f, 0x69, 0xcd, 0x82, 0x91, // start 0x61, 0xef, 0x3d, 0x98, // end 0x62, 0x03, 0x03, 0xdf, // wght 0x14, ] ``` -------------------------------- ### Initialize and Show MoonPay Web SDK - JavaScript Source: https://build.avax.network/integrations/moonpay This code demonstrates how to initialize and display the MoonPay Web SDK. It requires installation via npm and involves creating a MoonPayWebSdk instance with configuration options such as flow, environment, variant, and payment parameters. Event listeners for 'onClose' and 'onTransactionSuccess' are also included. ```javascript import { MoonPayWebSdk } from '@moonpay/moonpay-web-sdk'; const moonpay = new MoonPayWebSdk({ flow: 'buy', environment: 'production', // or 'sandbox' for testing variant: 'overlay', // or 'embedded' params: { apiKey: 'YOUR_API_KEY', currencyCode: 'avax', walletAddress: userWalletAddress, baseCurrencyCode: 'usd', baseCurrencyAmount: 100, externalTransactionId: 'YOUR_TRANSACTION_ID', // Optional theme: 'light', // or 'dark' showWalletAddressForm: true, lockAmount: false } }); // Open the widget moonpay.show(); // Listen to events moonpay.on('onClose', () => { console.log('Widget closed'); }); moonpay.on('onTransactionSuccess', (data) => { console.log('Transaction created:', data); }); ``` -------------------------------- ### AvalancheGo Installer Script Terminal Output Source: https://build.avax.network/llms-full Example output from the AvalancheGo installer script during the download and unpacking of node files. It displays the download URL, file size, and extraction process. ```bash AvalancheGo installer --------------------- Preparing environment... Found arm64 architecture... Looking for the latest arm64 build... Will attempt to download: https://github.com/ava-labs/avalanchego/releases/download/v1.1.1/avalanchego-linux-arm64-v1.1.1.tar.gz avalanchego-linux-arm64-v1.1.1.tar.gz 100%[=========================================================================>] 29.83M 75.8MB/s in 0.4s 2020-12-28 14:57:47 URL:https://github-production-release-asset-2e65be.s3.amazonaws.com/246387644/f4d27b00-4161-11eb-8fb2-156a992fd2c8?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201228%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201228T145747Z&X-Amz-Expires=300&X-Amz-Signature=ea838877f39ae940a37a076137c4c2689494c7e683cb95a5a4714c062e6ba018&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=246387644&response-content-disposition=attachment%3B%20filename%3Davalanchego-linux-arm64-v1.1.1.tar.gz&response-content-type=application%2Foctet-stream [31283052/31283052] -> "avalanchego-linux-arm64-v1.1.1.tar.gz" [1] Unpacking node files... avalanchego-v1.1.1/plugins/ avalanchego-v1.1.1/plugins/evm avalanchego-v1.1.1/avalanchego Node files unpacked into /home/ubuntu/avalanche-node ``` -------------------------------- ### Setup Web3Provider for BuilderKit Application Source: https://build.avax.network/llms-full Illustrates the basic setup for the Web3Provider in a React application. This involves importing necessary components and chain configurations, defining the list of supported chains, and wrapping the main application component with Web3Provider. Key props like `appName`, `projectId`, and `chains` are configured to enable wallet connections and chain management. ```tsx import { Web3Provider } from '@avalabs/builderkit'; import { avalanche, avalancheFuji } from '@wagmi/core/chains'; import { echo } from './chains/definitions/echo'; import { dispatch } from './chains/definitions/dispatch'; // Configure chains const chains = [avalanche, avalancheFuji, echo, dispatch]; function App() { return ( ); } ``` -------------------------------- ### Install Dependencies and Run Development Server (Bash) Source: https://build.avax.network/llms-full This snippet outlines the steps to clone a project repository, install its dependencies using yarn, and then run the project in development mode. It's essential for setting up the local development environment for the Telegram Mini-App. ```bash git clone cd yarn install yarn dev ``` -------------------------------- ### Build and Run x402-rs Facilitator Locally with Docker Source: https://build.avax.network/llms-full This sequence of commands outlines how to build the x402-rs project into a Docker image locally and then run it. It's an alternative to using prebuilt images and allows for custom builds. Ensure you have Docker installed and the project source code available. ```bash docker build -t x402-rs . docker run --env-file .env -p 8080:8080 x402-rs ``` -------------------------------- ### Implement HelloWorld Precompile Verification Logic Source: https://build.avax.network/llms-full Implements the `Verify()` method for the `Config` struct to validate the precompile's configuration. It first calls `AllowListConfig.Verify()` and then allows for custom verification logic to be added. An error is returned if any verification step fails, and the error is treated as fatal on startup. ```go // Verify tries to verify Config and returns an error accordingly. func (c *Config) Verify() error { // Verify AllowList first if err := c.AllowListConfig.Verify(); err != nil { return err } // CUSTOM CODE STARTS HERE // Add your own custom verify code for Config here // and return an error accordingly return nil } ``` -------------------------------- ### avax.getUTXOs Source: https://build.avax.network/llms-full Gets all UTXOs for the specified addresses. Supports filtering by chain, start index, and limit. The encoding can be specified for the output. ```APIDOC ## POST /ext/bc/C/avax ### Description Gets all UTXOs for the specified addresses. ### Method POST ### Endpoint /ext/bc/C/avax ### Parameters #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC version. - **id** (number) - Required - The ID of the request. - **method** (string) - Required - The method name, which is `avax.getUTXOs`. - **params** (array) - Required - An array containing the parameters for the method. - **addresses** (array of strings) - Required - A list of addresses to retrieve UTXOs for. - **sourceChain** (string) - Required - The chain from which to retrieve UTXOs (e.g., "X"). - **startIndex** (object) - Optional - Specifies the starting point for retrieving UTXOs. - **address** (string) - Required - The address to start from. - **utxo** (string) - Required - The UTXO ID to start from. - **limit** (number) - Optional - The maximum number of UTXOs to return. - **encoding** (string) - Optional - The encoding format for the UTXOs (e.g., "hex"). ### Request Example ```json { "jsonrpc":"2.0", "id" :1, "method" :"avax.getUTXOs", "params" :[{ "addresses": ["X-avax1..."], "sourceChain": "X", "limit": 100, "encoding": "hex" }] } ``` ### Response #### Success Response (200) - **utxos** (array of strings) - A list of UTXO IDs. - **endIndex** (object) - Information about the last UTXO returned, useful for pagination. - **address** (string) - The address of the last UTXO. - **utxo** (string) - The ID of the last UTXO. - **numFetched** (number) - The number of UTXOs fetched in this request. - **encoding** (string) - The encoding format of the UTXOs. #### Response Example ```json { "utxos": ["0x..."], "endIndex": { "address": "X-avax1...", "utxo": "0x..." }, "numFetched": 100, "encoding": "hex" } ``` ``` -------------------------------- ### Get Installed Virtual Machines (VMs) on a Node Source: https://build.avax.network/llms-full Retrieves a map of installed virtual machines on the current node. This endpoint is specific to a single node and is not available on the public server. It returns a map where keys are VM IDs and values are arrays of VM types. ```sh curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"info.getVMs", "params" :{} }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/info ``` -------------------------------- ### Go: Plugin Setup for AvalancheGo Integration Source: https://build.avax.network/llms-full Sets up the main package to serve the Timestamp VM as a plugin for AvalancheGo using `go-plugin`. It configures the handshake and registers the VM plugin, enabling gRPC communication between AvalancheGo and the VM. This is crucial for making the VM compatible with the Avalanche network. ```go package main import ( "os" "github.com/ava-labs/avalanchego/rpcchainvm/plugin" "github.com/ava-labs/avalanchego/rpcchainvm/plugin/rpcchainvm" "github.com/ava-labs/avalanchego/vms/timestampvm" "github.com/hashicorp/go-plugin" "github.com/hashicorp/go-plugin/testlog" "github.com/keptn/go-utils/pkg/log" ) func main() { log.Root().SetHandler(log.LvlFilterHandler(log.LvlDebug, log.StreamHandler(os.Stderr, log.TerminalFormat()))) plugin.Serve(&plugin.ServeConfig{ HandshakeConfig: rpcchainvm.Handshake, Plugins: map[string]plugin.Plugin{ "vm": rpcchainvm.New(×tampvm.VM{}), }, // A non-nil value here enables gRPC serving for this plugin... GRPCServer: plugin.DefaultGRPCServer, }) } ``` -------------------------------- ### Get Node ID Response Source: https://build.avax.network/llms-full This section details the response structure for the `info.getNodeID` method, highlighting the `nodeID` which is crucial for validator setup. ```APIDOC ## GET / 2.0 ### Description Retrieves the unique identifier for the Avalanche node. ### Method GET ### Endpoint / ### Parameters None ### Request Example None ### Response #### Success Response (200) - **result** (object) - Contains the node information. - **nodeID** (string) - The unique identifier for the node. (e.g., "NodeID-Q8Gfaaio9FAqCmZVEXDq9bFvNPvDi7rt5") - **nodePOP** (object) - Proof of Possession details. - **publicKey** (string) - The public key of the node. - **proofOfPossession** (string) - The proof of possession signature. - **jsonrpc** (string) - The JSON RPC version. - **id** (integer) - The request ID. #### Response Example ```json { "jsonrpc": "2.0", "result": { "nodeID": "NodeID-Q8Gfaaio9FAqCmZVEXDq9bFvNPvDi7rt5", "nodePOP": { "publicKey": "0x85675db18b326a9585bfd43892b25b71bf01b18587dc5fac136dc5343a9e8892cd6c49b0615ce928d53ff5dc7fd8945d", "proofOfPossession": "0x98a56f092830161243c1f1a613ad68a7f1fb25d2462ecf85065f22eaebb4e93a60e9e29649a32252392365d8f628b2571174f520331ee0063a94473f8db6888fc3a722be330d5c51e67d0d1075549cb55376e1f21d1b48f859ef807b978f65d9" } }, "id": 1 } ``` ``` -------------------------------- ### Get Container Range API Source: https://build.avax.network/llms-full Retrieves a range of containers specified by start and end indices. This is suitable for fetching multiple containers sequentially. ```APIDOC ## GET /index/getContainerRange ### Description Get range of containers by index. ### Method GET ### Endpoint /index/getContainerRange ### Parameters #### Query Parameters - **startIndex** (number) - Required - Index of the first container to retrieve - **endIndex** (number) - Required - Index of the last container to retrieve (inclusive) - **encoding** (string) - Required - Encoding format (only "hex" is supported) ### Request Example ```json { "startIndex": 1000, "endIndex": 1010, "encoding": "hex" } ``` ### Response #### Success Response (200) - **containers** (array) - Array of container details #### Response Example ```json { "containers": [ { "id": "0x123...", "bytes": "0xabc...", "timestamp": "2023-10-27T10:00:00Z", "encoding": "hex", "index": "1000" }, { "id": "0x456...", "bytes": "0xdef...", "timestamp": "2023-10-27T10:01:00Z", "encoding": "hex", "index": "1001" } ] } ``` ``` -------------------------------- ### Install Allbridge Core SDK using npm, yarn, or pnpm Source: https://build.avax.network/integrations/allbridge-core Instructions for installing the Allbridge Core SDK using different package managers. This is the first step to integrating cross-chain functionality into your project. ```bash $ npm install @allbridge/bridge-core-sdk ``` ```bash $ yarn add @allbridge/bridge-core-sdk ``` ```bash $ pnpm add @allbridge/bridge-core-sdk ``` -------------------------------- ### Setup and Authentication Source: https://build.avax.network/llms-full To use the API, you need to generate an API key from the AvaCloud portal. Authenticate your requests by including this key in the `x-glacier-api-key` header. ```APIDOC ## Setup and Authentication ### Description To utilize your account's rate limits, you need to make API requests with an API key. API Keys can be generated from the AvaCloud portal. Once created and retrieved, you can make authenticated queries by passing your API key in the `x-glacier-api-key` header of your HTTP request. ### Method GET ### Endpoint `/v1/chains` ### Parameters #### Header Parameters - **x-glacier-api-key** (string) - Required - Your unique API key for authentication. - **Content-Type** (string) - Required - Set to `Application/json`. ### Request Example ```bash curl -H "Content-Type: Application/json" -H "x-glacier-api-key: your_api_key" \ "https://glacier-api.avax.network/v1/chains" ``` ### Response #### Success Response (200) - **Data** (object) - Contains information about the chains. - **Message** (string) - Success message. - **Code** (integer) - HTTP status code (e.g., 200). #### Response Example ```json { "data": { "chains": [ { "id": "avax", "name": "Avalanche", "network": "mainnet" } ] }, "message": "Success", "code": 200 } ``` ``` -------------------------------- ### Get Subnet Validated Blockchain IDs (curl) Source: https://build.avax.network/docs/rpcs/p-chain This example demonstrates how to call the platform.validates API using curl to get the blockchain IDs validated by a specific Subnet. It requires the Subnet's ID as input and returns a list of associated blockchain IDs. ```curl curl -X POST --data '{ "jsonrpc": "2.0", "method": "platform.validates", "params": { "subnetID":"2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r" }, "id": 1 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P ``` -------------------------------- ### Get Container Range Source: https://build.avax.network/docs/tooling/avalanche-sdk/client/methods/public-methods/api Fetches a range of containers based on their start and end indices. This is efficient for retrieving multiple containers sequentially. ```APIDOC ## GET /index/containers ### Description Retrieves a range of containers specified by a start and end index. This allows for batch retrieval of container data. ### Method GET ### Endpoint `/index/containers` ### Parameters #### Query Parameters - **startIndex** (number) - Required - The index of the first container to retrieve. - **endIndex** (number) - Required - The index of the last container to retrieve (inclusive). - **encoding** (string) - Required - The encoding format for the container data. Only 'hex' is supported. ### Request Example ```javascript // Assuming 'client' is an initialized Avalanche client instance const range = await client.indexBlock.xChain.getContainerRange({ startIndex: 1000, endIndex: 1010, encoding: "hex" }); console.log(range); ``` ### Response #### Success Response (200) - **containers** (array) - An array of container objects. Each object contains: - **id** (string) - The unique identifier of the container. - **bytes** (string) - The byte representation of the container's data in hexadecimal format. - **timestamp** (string) - The timestamp when the container was accepted by the node. - **encoding** (string) - The encoding format used for the `bytes` field (always 'hex'). - **index** (string) - The index of the container as a string. #### Response Example ```json { "containers": [ { "id": "0xabc...", "bytes": "0x123...", "timestamp": "2023-10-27T09:50:00Z", "encoding": "hex", "index": "1000" }, { "id": "0xdef...", "bytes": "0x456...", "timestamp": "2023-10-27T09:51:00Z", "encoding": "hex", "index": "1001" } ] } ``` ``` -------------------------------- ### Install ZeroDev SDK using npm Source: https://build.avax.network/integrations/zerodev This command installs the ZeroDev SDK into your project using npm. It's the first step to integrating ZeroDev's account abstraction features into your application. ```bash npm install @zerodev/sdk ``` -------------------------------- ### Complete Workflow Example Source: https://build.avax.network/docs/tooling/avalanche-sdk/interchain/ictt/transfers Demonstrates a complete workflow for deploying tokens, setting up contracts, and transferring tokens across chains. ```APIDOC ## Complete Workflow Example ### Description This example illustrates the end-to-end process of using the Interchain Token Transfers API, from deploying contracts to sending tokens across different chains. ### Code Snippet ```javascript import { createICTTClient } from "@avalanche-sdk/interchain"; import { avalancheFuji, dispatch } from "@avalanche-sdk/interchain/chains"; // Initialize the ICTT client const ictt = createICTTClient(avalancheFuji, dispatch); // Assume 'wallet' is an authenticated WalletClient instance const wallet = {}; // Placeholder for wallet client const tokenHomeAddress = "0x..."; // Placeholder for token home contract address const tokenAddress = "0x..."; // Placeholder for token contract address const tokenRemoteAddress = "0x..."; // Placeholder for token remote contract address // 1. Deploy token // const { contractAddress: tokenAddress } = await ictt.deployERC20Token({ // walletClient: wallet, // sourceChain: avalancheFuji, // name: "My Token", // symbol: "MTK", // initialSupply: 1000000, // }); // 2. Deploy home contract // const { contractAddress: tokenHomeAddress } = await ictt.deployTokenHomeContract({ // walletClient: wallet, // sourceChain: avalancheFuji, // erc20TokenAddress: tokenAddress, // minimumTeleporterVersion: 1, // }); // 3. Deploy remote contract // const { contractAddress: tokenRemoteAddress } = await ictt.deployTokenRemoteContract({ // walletClient: wallet, // sourceChain: avalancheFuji, // destinationChain: dispatch, // tokenHomeContract: tokenHomeAddress, // }); // 4. Register remote with home // await ictt.registerRemoteWithHome({ // walletClient: wallet, // sourceChain: avalancheFuji, // destinationChain: dispatch, // tokenRemoteContract: tokenRemoteAddress, // }); // 5. Approve tokens for transfer await ictt.approveToken({ walletClient: wallet, sourceChain: avalancheFuji, tokenHomeContract: tokenHomeAddress, tokenAddress: tokenAddress, amountInBaseUnit: 1000, }); // 6. Send tokens to the destination chain const { txHash } = await ictt.sendToken({ walletClient: wallet, sourceChain: avalancheFuji, destinationChain: dispatch, tokenHomeContract: tokenHomeAddress, tokenRemoteContract: tokenRemoteAddress, recipient: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6", amountInBaseUnit: 100, }); console.log(`Token transfer initiated with transaction hash: ${txHash}`); ``` ``` -------------------------------- ### Run End-to-End Cross-Chain Messenger Tests Source: https://build.avax.network/llms-full This shell command executes the end-to-end tests for the example cross-chain messenger. The `GINKGO_FOCUS` environment variable is used to specifically target tests related to the 'Example cross chain messenger', ensuring that only relevant tests are run. This command initiates the local test environment setup and test execution. ```bash GINKGO_FOCUS="Example cross chain messenger" scripts/local/e2e_test.sh ``` -------------------------------- ### HTTP Request with X-PAYMENT Header Source: https://build.avax.network/llms-full Example of an HTTP GET request including the X-PAYMENT header with a base64-encoded payment payload. This demonstrates how clients should structure their retry requests after a 402 response. ```http GET /api/premium-data HTTP/1.1 Host: example.com X-PAYMENT: ``` -------------------------------- ### AvalancheGo Service Log Output Example Source: https://build.avax.network/llms-full An example of the log output from a running AvalancheGo service, showing initialization details, consensus engine status, API server information, and bootstrapping progress. ```text ● avalanchego.service - AvalancheGo systemd service Loaded: loaded (/etc/systemd/system/avalanchego.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-01-05 10:38:21 UTC; 51s ago Main PID: 2142 (avalanchego) Tasks: 8 (limit: 4495) Memory: 223.0M CGroup: /system.slice/avalanchego.service └─2142 /home/ubuntu/avalanche-node/avalanchego --public-ip-resolution-service=opendns --http-host= Jan 05 10:38:45 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:38:45]

avalanchego/vms/platformvm/vm.go#322: initializing last accepted block as 2FUFPVPxbTpKNn39moGSzsmGroYES4NZRdw3mJgNvMkMiMHJ9e Jan 05 10:38:45 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:38:45]

avalanchego/snow/engine/snowman/transitive.go#58: initializing consensus engine Jan 05 10:38:45 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:38:45] avalanchego/api/server.go#143: adding route /ext/bc/11111111111111111111111111111111LpoYY Jan 05 10:38:45 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:38:45] avalanchego/api/server.go#88: HTTP API server listening on ":9650" Jan 05 10:38:58 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:38:58]

avalanchego/snow/engine/common/bootstrapper.go#185: Bootstrapping started syncing with 1 vertices in the accepted frontier Jan 05 10:39:02 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:39:02]

avalanchego/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 2500 blocks Jan 05 10:39:04 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:39:04]

avalanchego/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 5000 blocks Jan 05 10:39:06 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:39:06]

avalanchego/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 7500 blocks Jan 05 10:39:09 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:39:09]

avalanchego/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 10000 blocks Jan 05 10:39:11 ip-172-31-30-64 avalanchego[2142]: INFO [01-05|10:39:11]

avalanchego/snow/engine/snowman/bootstrap/bootstrapper.go#210: fetched 12500 blocks ``` -------------------------------- ### Validator Byte Representation Example Source: https://build.avax.network/docs/rpcs/p-chain/txn-format Illustrates the byte-level representation of a Validator. It shows the hexadecimal conversion for a given NodeID, Start, End, and Wght. ```plaintext [ NodeID <- 0xaa18d3991cf637aa6c162f5e95cf163f69cd8291 Start <- 0x61ef3d98 End <- 0x620303df Wght <- 0x14 ] = [ // node id 0xaa, 0x18, 0xd3, 0x99, 0x1c, 0xf6, 0x37, 0xaa, 0x6c, 0x16, 0x2f, 0x5e, 0x95, 0xcf, 0x16, 0x3f, 0x69, 0xcd, 0x82, 0x91, // start 0x61, 0xef, 0x3d, 0x98, // end 0x62, 0x03, 0x03, 0xdf, // wght 0x14, ] ``` -------------------------------- ### Provide Path to VM Binary Source: https://build.avax.network/llms-full This snippet demonstrates providing the path to your pre-compiled VM binary. This is used when you have already built your VM and are deploying on a local network. ```bash ? How do you want to set up the VM binary?: Download and build from a git repository (recommended for cloud deployments) ▸ I already have a VM binary (local network deployments only) ✔ Enter path to vm binary: ./custom_vm.bin ``` -------------------------------- ### Fetch Latest Installer Script (Bash) Source: https://build.avax.network/llms-full Command to download the latest version of the avalanchego-installer.sh script from the official repository using wget. This is necessary to get the newest features or to recover from script issues. ```bash wget -nd -m https://raw.githubusercontent.com/ava-labs/builders-hub/master/scripts/avalanchego-installer.sh ``` -------------------------------- ### Example JSON Configuration for Precompile Source: https://build.avax.network/llms-full This JSON snippet shows the expected structure for configuring a precompile. The 'helloWorldConfig' key, matching the ConfigKey defined in module.go, holds the specific settings for the precompile, such as 'blockTimestamp'. This allows the EVM to read and apply the precompile's configuration. ```json { "helloWorldConfig": { "blockTimestamp": 0 } } ``` -------------------------------- ### VM Initialization Sequence Source: https://build.avax.network/llms-full Details the sequence of calls and expected responses for initializing a VM with AvalancheGo. ```APIDOC ## VM Initialization Sequence AvalancheGo manages the lifecycle of your VM binary. Upon starting your VM, AvalancheGo provides an environment variable `AVALANCHE_VM_RUNTIME_ENGINE_ADDR` which contains a URL. This URL is used to establish a connection for the `vm.Runtime` client. Your VM must implement a gRPC server that adheres to the VM interface. After starting this server, it should call `vm.Runtime.InitializeRequest` with the following parameters: - `protocolVersion` (integer): Must match the supported plugin version of the AvalancheGo release. This is typically found in the release notes. - `addr` (string): The address of your gRPC server in the format `host:port`, e.g., `localhost:12345`. ### Pre-Initialization Sequence Before the actual initialization, AvalancheGo may start and stop your VM process multiple times. During these pre-initialization phases, your VM is expected to implement the following methods: 1. **VM.Version** - **Description**: Returns the version of your VM. - **Method**: Unspecified (called by AvalancheGo) - **Endpoint**: N/A - **Response (Success)**: - `version` (string) - The version string of the VM. 2. **VM.CreateStaticHandler** - **Description**: Creates a static handler for the VM. This is not strictly required and can return an empty array. - **Method**: Unspecified (called by AvalancheGo) - **Endpoint**: N/A - **Response (Success)**: - `[]` (array) - An empty array if not implemented or required. 3. **VM.Shutdown** - **Description**: Gracefully stops your VM process. - **Method**: Unspecified (called by AvalancheGo) - **Endpoint**: N/A - **Response (Success)**: - Empty response. ``` -------------------------------- ### Initialize Avalanche SDK Client and Get Balance (TypeScript) Source: https://build.avax.network/llms-full Demonstrates how to initialize the Avalanche SDK client for the mainnet and retrieve the balance of a given address. This example requires the 'address' and 'chainId' as input. ```typescript import { createClient } from '@avalanche-sdk/client'; // Initialize the client const client = createClient({ network: 'mainnet' }); // Get balance const balance = await client.getBalance({ address: '0x...', chainId: 43114 }); console.log('Balance:', balance); ``` -------------------------------- ### JSON Response for Get Block by ID Source: https://build.avax.network/llms-full This is an example of a successful JSON response when requesting a block by its ID. It details the structure of the block, including its parentID, height, and transaction information, along with the encoding used. ```json { "jsonrpc": "2.0", "result": { "block": { "parentID": "5615di9ytxujackzaXNrVuWQy5y8Yrt8chPCscMr5Ku9YxJ1S", "height": 1000001, "txs": [ { "unsignedTx": { "inputs": { "networkID": 1, "blockchainID": "11111111111111111111111111111111LpoYY", "outputs": [], "inputs": [ { "txID": "DTqiagiMFdqbNQ62V2Gt1GddTVLkKUk2caGr4pyza9hTtsfta", "outputIndex": 0, "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", "input": { "amount": 13839124063, "signatureIndices": [0] } } ], "memo": "0x" }, "destinationChain": "2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5", "exportedOutputs": [ { "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", "output": { "addresses": [ "P-avax1jkjyvlwclyu42n4yuegpczpfgwrf8r9lyj0d3c" ], "amount": 13838124063, "locktime": 0, "threshold": 1 } } ] }, "credentials": [ { "signatures": [ "0xc79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed7385801" ] } ] } ] }, "encoding": "json" }, "id": 1 } ``` -------------------------------- ### Select Local Network Option Source: https://build.avax.network/llms-full Example of the interactive prompt presented during the Avalanche L1 deployment process. Users must select 'Local Network' to deploy the blockchain on their machine. ```bash ? Choose a network for the operation: ▸ Local Network Devnet Etna Devnet Fuji Testnet Mainnet ``` -------------------------------- ### JSON RPC Request Example (X-Chain API) Source: https://build.avax.network/llms-full Demonstrates how to make a JSON RPC 2.0 request to the X-Chain API to get a transaction status. This covers the request structure, method invocation, and parameter formatting. ```APIDOC ## JSON RPC Request Example (X-Chain API) ### Description This example shows how to query the status of a transaction on the X-Chain using the `avm.getTxStatus` method via JSON RPC 2.0. ### Method `POST` ### Endpoint `[node-ip]:[http-port]/ext/bc/X` ### Parameters #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON RPC protocol version (e.g., "2.0"). - **id** (number) - Required - Unique identifier for the request. - **method** (string) - Required - The method to invoke (e.g., "avm.getTxStatus"). - **params** (object) - Required - An object containing the parameters for the method. - **txID** (string) - Required - The ID of the transaction (in CB58 format). ### Request Example ```json { "jsonrpc": "2.0", "id": 4, "method": "avm.getTxStatus", "params": { "txID": "2QouvFWUbjuySRxeX5xMbNCuAaKWfbk5FeEa2JmoF85RKLk2dD" } } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON RPC protocol version. - **result** (object) - Contains the result of the method call. - **Status** (string) - The status of the transaction (e.g., "Accepted"). - **id** (number) - The ID of the request. #### Response Example ```json { "jsonrpc": "2.0", "result": { "Status": "Accepted" }, "id": 1 } ``` #### Error Response - **jsonrpc** (string) - The JSON RPC protocol version. - **error** (object) - Contains error details. - **code** (number) - The error code. - **message** (string) - A description of the error. - **data** (object) - Additional information about the error. - **id** (number) - The ID of the request. ```