### Simplify Get Server Creation Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Simplifies the process of creating a server instance. This aims to make server setup more straightforward and less error-prone. ```go func NewServer(...) { ... } ``` -------------------------------- ### Example GetUTXOs Response Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/platformvm/service.md This is an example response from the platform.getUTXOs method, showing fetched UTXOs and pagination information. ```json { "jsonrpc": "2.0", "result": { "numFetched": "5", "utxos": [ "0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765", "0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a", "0x0000731ce04b1feefa9f4291d869adc30a33463f315491e164d89be7d6d2d7890cfc00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21600dd3047", "0x0000b462030cc4734f24c0bc224cf0d16ee452ea6b67615517caffead123ab4fbf1500000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c71b387e", "0x000054f6826c39bc957c0c6d44b70f961a994898999179cc32d21eb09c1908d7167b00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f2166290e79d" ], "endIndex": { "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "utxo": "kbUThAUfmBXUmRgTpgD6r3nLj7rJUGho6xyht5nouNNypH45j" }, "encoding": "hex" }, "id": 1 } ``` ```json { "jsonrpc": "2.0", "result": { "numFetched": "4", "utxos": [ "0x000020e182dd51ee4dcd31909fddd75bb3438d9431f8e4efce86a88a684f5c7fa09300000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21662861d59", "0x0000a71ba36c475c18eb65dc90f6e85c4fd4a462d51c5de3ac2cbddf47db4d99284e00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21665f6f83f", "0x0000925424f61cb13e0fbdecc66e1270de68de9667b85baa3fdc84741d048daa69fa00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216afecf76a", "0x000082f30327514f819da6009fad92b5dba24d27db01e29ad7541aa8e6b6b554615c00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216779c2d59" ], "endIndex": { "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "utxo": "21jG2RfqyHUUgkTLe2tUp6ETGLriSDTW3th8JXFbPRNiSZ11jK" }, "encoding": "hex" }, "id": 1 } ``` -------------------------------- ### Install XSVM Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/example/xsvm/README.md Clone the avalanchego repository and install the XSVM command-line tool. Ensure you are in the avalanchego directory before running the install command. ```bash git clone https://github.com/ava-labs/avalanchego.git; cd avalanchego; go install -v ./vms/example/xsvm/cmd/xsvm; ``` -------------------------------- ### Install Protobuf and gRPC Go Generators Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/README.md Installs the necessary protoc-gen-go and protoc-gen-go-grpc plugins. Ensure your GOPATH is set correctly. ```go go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 ``` -------------------------------- ### Add X-chain CreateAssetTx Example Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Example demonstrating how to use the wallet to create an X-chain CreateAssetTx. This is useful for defining new assets on the X-chain. ```go func main() { // ... other initialization // Example of creating a CreateAssetTx // This requires specifying asset details like name, symbol, and denominations. assetName := "MyToken" assetSymbol := "MTK" denominations := uint8(18) createAssetTx, err := wallet.XChain().CreateAssetTx(assetName, assetSymbol, denominations) if err != nil { log.Fatalf("Failed to create CreateAssetTx: %v", err) } fmt.Printf("Successfully created CreateAssetTx: %s\n", createAssetTx.ID()) // ... further processing or broadcasting of the transaction } ``` -------------------------------- ### Add GetBalance Examples for P-chain and X-chain Wallets Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Provides example usage for the `GetBalance` function for both P-chain and X-chain wallets. These examples demonstrate how to retrieve account balances. ```go // Add GetBalance examples for the P-chain and X-chain wallets ``` -------------------------------- ### Install and Initialize Smartcard Application Source: https://github.com/flare-foundation/go-flare/blob/main/coreth/accounts/scwallet/README.md Use the keycard-cli to install the smartcard application and initialize the card. This process generates a PIN, PUK, and pairing password. ```bash keycard install -a keycard_v2.2.1.cap && keycard init ``` -------------------------------- ### Start and Stop Temporary Network with tmpnetctl Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/tests/fixture/tmpnet/README.md Demonstrates how to start a new temporary network and stop an existing one using the tmpnetctl CLI. Ensure to provide the correct path to your avalanchego executable when starting the network. ```bash # From the root of the avalanchego repo # Start a new network. Possible to specify the number of nodes (> 1) with --node-count. $ ./bin/tmpnetctl start-network --avalanchego-path=/path/to/avalanchego ... Started network /home/me/.tmpnet/networks/20240306-152305.924531 (UUID: abaab590-b375-44f6-9ca5-f8a6dc061725) Configure tmpnetctl to target this network by default with one of the following statements: - source /home/me/.tmpnet/networks/20240306-152305.924531/network.env - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/20240306-152305.924531 - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/latest # Stop the network $ ./bin/tmpnetctl stop-network --network-dir=/path/to/network ``` -------------------------------- ### Start Local Testnet with avalanche-cli Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/README.md Use the avalanche-cli tool to start a local Avalanche network. This is the recommended method for local testing. ```sh avalanche network start ``` -------------------------------- ### Start CPU Profiler with admin.startCPUProfiler Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/api/admin/service.md Starts profiling the CPU utilization of the node. Call `admin.stopCPUProfiler` to stop and write the profile. ```sh curl -X POST --data '{ "jsonrpc":"2.0", "id" :1, "method" :"admin.startCPUProfiler", "params" :{} }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin ``` ```json { "jsonrpc": "2.0", "id": 1, "result": {} } ``` -------------------------------- ### AvalancheGo Documentation: Wallet Example Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Adds a wallet example demonstrating how to create `stakeable.LockOut` outputs. This provides practical guidance for developers using the wallet functionalities. ```go // Added wallet example to create stakeable.LockOut outputs ``` -------------------------------- ### Add X-chain CreateAssetTx Example (Go) Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Demonstrates how to use the wallet to create an asset on the X-chain. This example is relevant for developers working with the Avalanche Virtual Machine (AVM). ```go package main import ( "fmt" "github.com/ava-labs/avalanchego/vms/avm" "github.com/ava-labs/avalanchego/wallet/chain/x" ) func main() { // Example usage of CreateAssetTx // This is a placeholder and requires actual wallet and chain initialization. fmt.Println("Example for X-chain CreateAssetTx using wallet.") // assetTx, err := x.NewCreateAssetTx( // // ... parameters for CreateAssetTx ... // ) // if err != nil { // // handle error // } // fmt.Printf("Created asset transaction: %s\n", assetTx.ID()) } ``` -------------------------------- ### Example Response for platform.getStake Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/platformvm/service.md An example JSON response from the platform.getStake method, detailing staked amounts, outputs, and encoding. ```json { "jsonrpc": "2.0", "result": { "staked": "6500000000000", "stakeds": { "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z": "6500000000000" }, "stakedOutputs": [ "0x000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff00000007000005e96630e800000000000000000000000001000000011f1c933f38da6ba0ba46f8c1b0a7040a9a991a80dd338ed1" ], "encoding": "hex" }, "id": 1 } ``` -------------------------------- ### Add P-chain RemoveSubnetValidatorTx Example Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Example demonstrating how to use the wallet to create a P-chain RemoveSubnetValidatorTx. This is useful for managing subnet validator participation. ```go func main() { // ... other initialization // Example of creating a RemoveSubnetValidatorTx // This requires a valid P-chain address and subnet ID. // Replace with actual values. validatorAddress := "" subnetID := "" removeTx, err := wallet.PChain().RemoveSubnetValidatorTx(validatorAddress, subnetID) if err != nil { log.Fatalf("Failed to create RemoveSubnetValidatorTx: %v", err) } fmt.Printf("Successfully created RemoveSubnetValidatorTx: %s\n", removeTx.ID()) // ... further processing or broadcasting of the transaction } ``` -------------------------------- ### Add Additional Payload.Hash Examples (Go) Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md This commit provides more examples for the `payload.Hash` function. Comprehensive examples are crucial for developers to understand how to correctly use this hashing utility. ```Go import "github.com/flare-foundation/go-flare/payload" func main() { data := []byte("example data") hash := payload.Hash(data) fmt.Printf("Hash: %x\n", hash) } ``` -------------------------------- ### Install AvalancheGo via APT Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/README.md Install the avalanchego package after adding the APT repository. Ensure your package list is updated first. ```sh sudo apt update sudo apt install avalanchego ``` -------------------------------- ### Example Response for platform.getRewardUTXOs Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/platformvm/service.md An example JSON response from the platform.getRewardUTXOs method, showing fetched UTXO count, encoded UTXOs, and encoding type. ```json { "jsonrpc": "2.0", "result": { "numFetched": "2", "utxos": [ "0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765", "0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a" ], "encoding": "hex" }, "id": 1 } ``` -------------------------------- ### Add P-chain Indexer API Example (Go) Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Introduces an example for the P-chain indexer API, likely to demonstrate how to interact with or utilize this functionality. This would be useful for developers building on or integrating with the Avalanche P-chain. ```Go package main import ( "fmt" "net/http" ) func main() { resp, err := http.Get("http://localhost:9650/ext/bc/P") if err != nil { fmt.Printf("Error making request: %s\n", err) return } defer resp.Body.Close() // Process the response from the P-chain indexer API fmt.Printf("Status Code: %d\n", resp.StatusCode) } ``` -------------------------------- ### Get Installed Virtual Machines Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/api/info/service.md Retrieves a map of installed virtual machines on the current node. This endpoint is specific to a node and unavailable on the public server. ```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 ``` ```json { "jsonrpc": "2.0", "result": { "vms": { "jvYyfQTxGMJLuGWa55kdP2p2zSUYsQ5Raupu4TW34ZAUBAbtq": ["avm"], "mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6": ["evm"], "qd2U4HDWUvMrVUeTcCHp6xH3Qpnn1XbU5MDdnBoiifFqvgXwT": ["nftfx"], "rWhpuQPF1kb72esV2momhMuTYGkEb1oL29pt2EBXWmSy4kxnT": ["platform"], "rXJsCSEYXg2TehWxCEEGj6JU2PWKTkd6cBdNLjoe2SpsKD9cy": ["propertyfx"], "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ": ["secp256k1fx"] } }, "id": 1 } ``` -------------------------------- ### Start Temporary Network Monitoring Collectors Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/tests/fixture/tmpnet/README.md Starts collectors for logs and metrics. Requires Prometheus and Loki credentials to be set as environment variables. Ensure promtail and prometheus binaries are available in your PATH, for example, by using 'nix develop'. ```bash # Start a nix shell to ensure the availability of promtail and prometheus. nix develop # Enable collection of logs and metrics PROMETHEUS_USERNAME= \ PROMETHEUS_PASSWORD= \ LOKI_USERNAME= \ LOKI_PASSWORD= \ ./bin/tmpnetctl start-collectors # Network start emits link to grafana displaying collected logs and metrics ./bin/tmpnetctl start-network # When done with the network, stop the collectors ./bin/tmpnetctl stop-collectors ``` -------------------------------- ### Building and Running the Node Source: https://context7.com/flare-foundation/go-flare/llms.txt Instructions for cloning the repository, building the go-flare node from source, and running it with different network configurations or custom settings. ```APIDOC ## Building and Running the Node ### Description Build the go-flare node from source and start it for local or network deployment. ### Build and Run Commands ```bash # Clone and build git clone https://github.com/flare-foundation/go-flare.git cd go-flare/avalanchego && ./scripts/build.sh # Run the node (connects to mainnet by default) ./build/avalanchego # Run with specific network ./build/avalanchego --network-id=flare ./build/avalanchego --network-id=songbird ./build/avalanchego --network-id=coston # Flare testnet ./build/avalanchego --network-id=coston2 # Songbird testnet # Run with custom configuration ./build/avalanchego \ --http-host=0.0.0.0 \ --http-port=9650 \ --staking-port=9651 \ --db-dir=/data/flare/db \ --log-dir=/data/flare/logs \ --log-level=info ``` ``` -------------------------------- ### Get Container Range Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/indexer/service.md Retrieves a list of containers starting from a specified index and fetching a defined number of items. Handles cases for empty responses, out-of-bounds indices, exceeding maximum fetch limits, and running out of transactions. ```APIDOC ## index.getContainerRange ### Description Returns the transactions at index [`startIndex`], [`startIndex+1`], ... , [`startIndex+n-1`]. - If [`n`] == 0, returns an empty response (for example: null). - If [`startIndex`] > the last accepted index, returns an error (unless the above apply.) - If [`n`] > [`MaxFetchedByRange`], returns an error. - If we run out of transactions, returns the ones fetched before running out. - `numToFetch` must be in `[0,1024]`. ### Method POST ### Endpoint `/ext/index/X/tx` ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version, typically "2.0". - **method** (string) - Required - The method name, "index.getContainerRange". - **params** (object) - Required - Parameters for the method. - **startIndex** (uint64) - Required - The beginning index. - **numToFetch** (uint64) - Required - The number of containers to fetch. Must be between 0 and 1024. - **encoding** (string) - Required - The encoding format, must be "hex". - **id** (integer) - Required - The request ID. ### Request Example ```json { "jsonrpc": "2.0", "method": "index.getContainerRange", "params": { "startIndex":0, "numToFetch":100, "encoding": "hex" }, "id": 1 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (integer) - The request ID. - **result** (array) - An array of container objects. - **id** (string) - The container's ID. - **bytes** (string) - The byte representation of the container. - **timestamp** (string) - The time at which this node accepted the container. - **encoding** (string) - The encoding format, "hex" only. - **index** (string) - How many containers were accepted in this index before this one. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": [ { "id": "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY", "bytes": "0x00000000000400003039d891ad56056d9c01f18f43f58b5c784ad07a4a49cf3d1f11623804b5cba2c6bf00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000070429ccc5c5eb3b80000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000050429d069189e0000000000010000000000000000c85fc1980a77c5da78fe5486233fc09a769bb812bcb2cc548cf9495d046b3f1b00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000100000009000000011cdb75d4e0b0aeaba2ebc1ef208373fedc1ebbb498f8385ad6fb537211d1523a70d903b884da77d963d56f163191295589329b5710113234934d0fd59c01676b00b63d2108", "timestamp": "2021-04-02T15:34:00.262979-07:00", "encoding": "hex", "index": "0" } ] } ``` ``` -------------------------------- ### Open Smartcard Wallet (Usage Example) Source: https://github.com/flare-foundation/go-flare/blob/main/coreth/accounts/scwallet/README.md Initiate the smartcard wallet connection using its URL. This command will prompt for the pairing password and then the PIN. ```javascript personal.openWallet("keycard://a4d73015") ``` -------------------------------- ### Build and Run go-flare Node Source: https://context7.com/flare-foundation/go-flare/llms.txt Clone the repository, build the node using the provided script, and run it. You can specify network IDs like 'flare', 'songbird', or testnets, and customize configuration options. ```bash git clone https://github.com/flare-foundation/go-flare.git cd go-flare/avalanchego && ./scripts/build.sh ``` ```bash ./build/avalanchego ``` ```bash ./build/avalanchego --network-id=flare ./build/avalanchego --network-id=songbird ./build/avalanchego --network-id=coston # Flare testnet ./build/avalanchego --network-id=coston2 # Songbird testnet ``` ```bash ./build/avalanchego \ --http-host=0.0.0.0 \ --http-port=9650 \ --staking-port=9651 \ --db-dir=/data/flare/db \ --log-dir=/data/flare/logs \ --log-level=info ``` -------------------------------- ### Example Response for platform.getStakingAssetID Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/platformvm/service.md An example JSON response from the platform.getStakingAssetID method, containing the assetID for the specified Subnet. ```json { "jsonrpc": "2.0", "result": { "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe" }, "id": 1 } ``` -------------------------------- ### Cross Subnet Transaction Example Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/example/xsvm/README.md Example of performing cross-subnet transactions using export and import Txs. ```APIDOC ## Cross Subnet Transaction Example This example demonstrates how to send and receive native assets across subnets using the XSVM. ### Overview of Steps 1. Create & deploy Subnet A 2. Create & deploy Subnet B 3. Issue an **export** Tx on Subnet A 4. Issue an **import** Tx on Subnet B 5. Confirm Txs processed correctly > **Note:** This demo requires avalanche-cli version > 1.0.5, xsvm version > 1.0.2 and avalanche-network-runner v1.3.5. ### Create and Deploy Subnet A, Subnet B Using the avalanche-cli, this step deploys two subnets running the XSVM. Subnet A will act as the sender in this demo, and Subnet B will act as the receiver. #### Steps 1. Build the [XSVM](https://github.com/ava-labs/xsvm) 2. Create a genesis file: ```bash xsvm chain genesis --encoding binary > xsvm.genesis ``` 3. Create Subnet A and Subnet B: ```bash avalanche subnet create subnetA --custom --genesis --vm avalanche subnet create subnetB --custom --genesis --vm ``` 4. Deploy Subnet A and Subnet B: ```bash avalanche subnet deploy subnetA --local avalanche subnet deploy subnetB --local ``` ### Issue Export Tx from Subnet A The SubnetID and ChainIDs are stored in the sidecar.json files in your avalanche-cli directory. Typically this is located at $HOME/.avalanche/subnets/ ```bash xsvm issue export --source-chain-id --amount --destination-chain-id ``` Save the TxID printed out by running the export command. ### Issue Import Tx from Subnet B > Note: The import tx requires **snowman++** consensus to be activated on the importing chain. A chain requires ~3 blocks to be produced for snowman++ to start. > Run `xsvm issue transfer --chain-id --amount 1000` to issue simple Txs on SubnetB ```bash xsvm issue import --source-chain-id --destination-chain-id --tx-id --source-uris ``` > The can be found by running `avalanche network status`. The default URIs are > "http://localhost:9650,http://localhost:9652,http://localhost:9654,http://localhost:9656,http://localhost:9658" ### Account Values To check proper execution, use the `xsvm account` command to check balances. Verify the balance on SubnetA decreased by your export amount using: ```bash xsvm account --chain-id ``` Now verify chain A's assets were successfully imported to SubnetB: ```bash xsvm account --chain-id --asset-id ``` ``` -------------------------------- ### Geth Console Output with Smartcard Wallet Info Source: https://github.com/flare-foundation/go-flare/blob/main/coreth/accounts/scwallet/README.md Example output from the geth console showing the status of smartcard wallets, including accounts and their URLs. This output is observed after successful wallet initialization. ```json { listAccounts: [], listWallets: [{ status: "Empty, waiting for initialization", url: "keycard://044def09" }], ... } ``` -------------------------------- ### xsvm.network API Response Example Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/example/xsvm/README.md Example JSON response from the xsvm.network API, showing the networkID, subnetID, and chainID. ```json > {"jsonrpc":"2.0","result":{"networkID":1000000,"subnetID":"2gToFoYXURMQ6y4ZApFuRZN1HurGcDkwmtvkcMHNHcYarvsJN1","chainID":"28iioW2fYMBnKv24VG5nw9ifY2PsFuwuhxhyzxZB5MmxDd3rnT"},"id":1} ``` -------------------------------- ### admin.loadVMs Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/api/admin/service.md Dynamically loads any virtual machines installed on the node as plugins. Refer to the virtual machines documentation for installation instructions. ```APIDOC ## POST /ext/admin ### Description Dynamically loads virtual machines installed on the node as plugins. ### Method POST ### Endpoint /ext/admin ### Parameters #### Request Body - **method** (string) - Required - The method to call, which is "admin.loadVMs". - **id** (integer) - Required - The request ID. - **params** (object) - Optional - An empty object for this method. ### Request Example ```json { "jsonrpc":"2.0", "id" :1, "method" :"admin.loadVMs", "params" :{} } ``` ### Response #### Success Response (200) - **newVMs** (map[string][]string) - A map where keys are VM IDs and values are lists of loaded VM names. - **failedVMs** (map[string]string) - Optional - A map where keys are VM IDs and values are error messages for VMs that failed to load. This field is only included if at least one VM fails to load. #### Response Example ```json { "jsonrpc": "2.0", "result": { "newVMs": { "tGas3T58KzdjLHhBDMnH2TvrddhqTji5iZAMZ3RXs2NLpSnhH": ["foovm"] }, "failedVMs": { "rXJsCSEYXg2TehWxCEEGj6JU2PWKTkd6cBdNLjoe2SpsKD9cy": "error message" } }, "id": 1 } ``` ``` -------------------------------- ### Get Current P-Chain Timestamp Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/vms/platformvm/service.md Retrieves the current timestamp from the P-Chain. This is a simple call to get the current time on the network. ```javascript platform.getTimestamp() -> {time: string} ``` ```shell curl -X POST --data '{ "jsonrpc": "2.0", "method": "platform.getTimestamp", "params": {}, "id": 1 } }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P ``` ```json { "jsonrpc": "2.0", "result": { "timestamp": "2021-09-07T00:00:00-04:00" }, "id": 1 } ``` -------------------------------- ### Open Smartcard Wallet with Pairing Password Source: https://github.com/flare-foundation/go-flare/blob/main/coreth/accounts/scwallet/README.md After initializing the smartcard, open the wallet in the geth console using the obtained pairing password. This step is necessary before proceeding with PIN authentication. ```javascript > personal.openWallet("keycard://044def09", "pairing password") ``` -------------------------------- ### Docker Deployment Source: https://context7.com/flare-foundation/go-flare/llms.txt Instructions for deploying go-flare nodes using Docker, including pulling the official image, verifying its signature, and running containers with persistent storage or environment variables. ```APIDOC ## Docker Deployment ### Description Run go-flare nodes using Docker containers with signed images. ### Docker Commands ```bash # Pull the official image docker pull ghcr.io/flare-foundation/go-flare:latest # Verify image signature cosign verify \ --certificate-identity-regexp="^https://github\.com/flare-foundation/go-flare/\.github/workflows/build-container\.yml@" \ --certificate-oidc-issuer=https://token.actions.githubusercontent.com \ ghcr.io/flare-foundation/go-flare:latest # Run container with persistent storage docker run -d \ --name flare-node \ -p 9650:9650 \ -p 9651:9651 \ -v /data/flare:/root/.avalanchego \ ghcr.io/flare-foundation/go-flare:latest \ /avalanchego/build/avalanchego \ --http-host=0.0.0.0 # Run with environment variables for complete validator info docker run -d \ --name flare-node \ -e COMPLETE_GET_VALIDATORS=true \ -p 9650:9650 \ -p 9651:9651 \ ghcr.io/flare-foundation/go-flare:latest ``` ``` -------------------------------- ### Build and Run Local Flare Network Source: https://github.com/flare-foundation/go-flare/blob/main/test-scripts/README.md Build the avalanchego binary and then run the localflare network. Ensure Node.js version >=20 and yarn are installed. ```bash ./scripts/build.sh ./scripts/localflare.sh ``` -------------------------------- ### Example Response for isAccepted (JSON) Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/indexer/service.md This is an example of the JSON response for the `index.isAccepted` method, indicating whether the provided container ID has been accepted. ```json { "jsonrpc": "2.0", "result": { "isAccepted": true }, "id": 1 } ``` -------------------------------- ### Build AvalancheGo Binary Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/CONTRIBUTING.md Execute this script to build the avalanchego binary. This is a prerequisite for local testing. ```sh ./scripts/build.sh ``` -------------------------------- ### Configure and Bootstrap Temporary Network in Go Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/tests/fixture/tmpnet/README.md Use this to configure and bootstrap a temporary network programmatically. It allows detailed setup of network defaults, nodes, and subnets with custom configurations. Ensure the paths to `avalanchego` and plugins are correct. ```golang network := &tmpnet.Network{ DefaultRuntimeConfig{ ReuseDynamicPorts: true, }, DefaultFlags: tmpnet.FlagsMap{ config.LogLevelKey: "INFO", }, Nodes: tmpnet.NewNodesOrPanic(5), Subnets: []*tmpnet.Subnet{ { Name: "xsvm-a", Chains: []*tmpnet.Chain{ { VMName: "xsvm", Genesis: , PreFundedKey: , VersionArgs: "version-json", }, }, ValidatorIDs: , }, }, } _ := tmpnet.BootstrapNewNetwork( ctx, ginkgo.GinkgoWriter, network, "", "/path/to/avalanchego", "/path/to/plugins", ) uris := network.GetNodeURIs() // Use URIs to interact with the network // Stop all nodes in the network network.Stop(context.Background()) ``` -------------------------------- ### Example Avalanche L1 Response Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/api/info/service.md This is an example JSON response from an Avalanche L1 network, showing rewarding stake and weighted average percentages. ```json { "jsonrpc": "2.0", "id": 1, "result": { "rewardingStakePercentage": "74.0741", "weightedAveragePercentage": "72.4074" } } ``` -------------------------------- ### Start CPU profiler Source: https://context7.com/flare-foundation/go-flare/llms.txt Initiate CPU profiling on the node using the Admin API. This is useful for performance analysis and identifying bottlenecks. ```bash curl -X POST --data '{ "jsonrpc":"2.0", "id":1, "method":"admin.startCPUProfiler", "params":{} }' -H 'content-type:application/json;' http://127.0.0.1:9650/ext/admin ``` -------------------------------- ### Example State Sync IPs Configuration Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/config/config.md Configure comma-separated IP:port pairs for state synchronization. These IPs are contacted to authenticate the state summary. The number of IPs must match the number of IDs provided for state sync. ```bash --state-sync-ips="127.0.0.1:12345,1.2.3.4:5678" ``` -------------------------------- ### AvalancheGo v1.10.11 Fix: Default Validator Start Time Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md This fix in v1.10.11 corrects the default start time for validators. Ensuring the correct default start time is crucial for proper validator scheduling and network participation. ```Go // In v1.10.11, the default validator start time is fixed. // This ensures validators begin their operation at the correct time. // Example of corrected logic (conceptual): // validator.StartTime = time.Now().Add(defaultLeeway) ``` -------------------------------- ### Document host and port behavior in help text Source: https://github.com/flare-foundation/go-flare/blob/main/avalanchego/RELEASES.md Adds documentation to the help text explaining the behavior of host and port configurations. This improves user understanding of how to configure network connectivity for the application. ```Go import ( "flag" "fmt" ) var ( host = flag.String("host", "localhost", "The hostname or IP address to bind to.") port = flag.Int("port", 9650, "The port to listen on.") ) func init() { flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0]) flag.PrintDefaults() fmt.Println("\nHost behavior: If set to 0.0.0.0, the server will listen on all available network interfaces.") fmt.Println("Port behavior: Specifies the TCP port for incoming connections.") } } ```