### Download and Install GWAN Binary Source: https://docs.wanchain.org/pos-validator-nodes/mainnet-node-setup-manually Downloads the GWAN binary for Linux, extracts the archive, and navigates to the directory. It also verifies the installation by checking the current version. ```bash wget https://github.com/wanchain/go-wanchain/releases/download/v2.1.2/gwan-linux-amd64-2.1.2-e7e0f23d.tar.gz tar -zxvf gwan-linux-amd64-2.1.2-e7e0f23d.tar.gz cd gwan-linux-amd64-2.1.2-e7e0f23d ./gwan version ``` -------------------------------- ### Install Docker on Ubuntu Source: https://docs.wanchain.org/pos-validator-nodes/delegation-guide This snippet provides the commands to install Docker on an Ubuntu system. It downloads and executes the Docker installation script, adds the current user to the docker group, and then exits the current shell session to apply group changes. ```bash $ sudo wget -qO- https://get.docker.com/ | sh $ sudo usermod -aG docker YourUserName $ exit ``` -------------------------------- ### Download Wanchain Binary (Linux AMD64) Source: https://docs.wanchain.org/pos-validator-nodes/run-rpc-node-guide Downloads the latest Wanchain client binary for Linux AMD64 architecture. This is the first step in setting up a node manually. Ensure you have `wget` installed. ```bash wget https://github.com/wanchain/go-wanchain/releases/download/v3.0.2/gwan-linux-amd64.tgz ``` -------------------------------- ### Manage Wanchain Accounts Source: https://docs.wanchain.org/pos-validator-nodes/mainnet-node-setup-manually Commands to generate a new validator account and retrieve the necessary public keys (key1 and key3) required for node registration. ```bash ./gwan account new ./gwan account pubkeys [ADDRESS] [PASSWORD] ``` -------------------------------- ### Run Wanchain Testnet RPC Node (Binary) Source: https://docs.wanchain.org/pos-validator-nodes/run-rpc-node-guide Starts a Wanchain RPC node for the testnet using the downloaded binary. The `--testnet` flag is added to the standard mainnet command. Supports both archive and full modes. ```bash ./gwan --testnet --http --http.addr 0.0.0.0 --http.port 8545 ``` ```bash ./gwan --testnet --gcmode=full --http --http.addr 0.0.0.0 --http.port 8545 ``` -------------------------------- ### Initialize GWAN Validator Node Source: https://docs.wanchain.org/pos-validator-nodes/mainnet-node-setup-manually Starts the GWAN node in the foreground using the specified address for mining and unlocking. Requires manual password entry and is intended for foreground execution. ```bash ./gwan --etherbase [ADDRESS] --unlock [ADDRESS] --mine ``` -------------------------------- ### Run Wanchain Mainnet RPC Node (Binary) Source: https://docs.wanchain.org/pos-validator-nodes/run-rpc-node-guide Starts a Wanchain RPC node for the mainnet using the downloaded binary. It can be run in archive mode (default) or full mode to save disk space. Requires the binary to be extracted and renamed. ```bash ./gwan --http --http.addr 0.0.0.0 --http.port 8545 ``` ```bash ./gwan --gcmode=full --http --http.addr 0.0.0.0 --http.port 8545 ``` -------------------------------- ### Run Wanchain Node and Interact via Gwan CLI Source: https://docs.wanchain.org/pos-validator-nodes/delegation-guide This code demonstrates how to run a Wanchain node using Docker and interact with it via the `gwan` command-line interface. It includes starting the node in detached mode, attaching to the container, creating a new account, and retrieving staking information. ```bash $ docker run -d -v /home/YourUserName/.wanchain:/root/.wanchain wanchain/wanpos /bin/gwan YourContainerID $ docker exec -it YourContainerID /bin/bash root> gwan attach .wanchain/gwan.ipc > personal.newAccount('YourPassword') "YourAccountAddress" > pos.getStakerInfo(eth.blockNumber) [ {...}, {...}, { Address: "DelegateAddress", Amount: 2e+23, Clients: [], FeeRate: 10, From: "...", LockEpochs: 30, PubBn256: "...", PubSec256: "...", StakingEpoch: 117 } ] ``` -------------------------------- ### Run Wanchain Mainnet RPC Node (Docker) Source: https://docs.wanchain.org/pos-validator-nodes/run-rpc-node-guide Launches a Wanchain mainnet RPC node using Docker. This command maps the necessary ports, sets up a volume for data persistence, and runs the node in full mode. Requires Docker to be installed. ```bash sudo docker run -d --name wanchain-node -v /home/ubuntu/wanchain:/root -p 8545:8545 -p 17717:17717 wanchain/client-go:3.0.2 gwan --gcmode=full --http --http.addr 0.0.0.0 --http.port 8545 ``` -------------------------------- ### Example API Response (All Chains) Source: https://docs.wanchain.org/developers/xflows-api This is an example of the JSON response when requesting all supported tokens without specifying a chain. The response is structured by `chainId`, with each chain containing a list of its supported `tokens`. ```JSON { "success": true, "data": [ { "chainId": 1, "tokens": [ { "decimals": "6", "tokenContractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7", "tokenLogoUrl": "https://xflows.wanchain.org/Token/USDT.png", "tokenName": "Tether", "tokenSymbol": "USDT", "asciiTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7" }, { "decimals": "6", "tokenContractAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "tokenLogoUrl": "https://xflows.wanchain.org/Token/USDC.png", "tokenName": "USDC", "tokenSymbol": "USDC", "asciiTokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" }, ... ] } ] } ``` -------------------------------- ### Configure SSH Access for AWS EC2 Source: https://docs.wanchain.org/pos-validator-nodes/getting-started-with-aws Commands to set the correct file permissions for the private key and initiate an SSH session to the EC2 instance. These commands are essential for secure remote access to the Linux-based virtual machine. ```bash chmod 400 your_keyfile.pem ssh -i your_keyfile.pem ubuntu@your_EC2_ip_address ``` -------------------------------- ### Example API Response (Specific Chain) Source: https://docs.wanchain.org/developers/xflows-api This is an example of the JSON response received when requesting supported tokens for a specific chain (e.g., chainId=10). It includes details for each token such as decimals, contract address, logo URL, name, and symbol. ```JSON { "success": true, "data": [ { "decimals": "6", "tokenContractAddress": "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58", "tokenLogoUrl": "https://xflows.wanchain.org/Token/USDT.png", "tokenName": "Tether USD", "tokenSymbol": "USDT", "asciiTokenAddress": "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58" }, { "decimals": "6", "tokenContractAddress": "0x0b2c639c533813f4aa9d7837caf62653d097ff85", "tokenLogoUrl": "https://xflows.wanchain.org/Token/USDC.png", "tokenName": "usdc", "tokenSymbol": "USDC", "asciiTokenAddress": "0x0b2c639c533813f4aa9d7837caf62653d097ff85" }, { "decimals": "18", "tokenContractAddress": "0x0000000000000000000000000000000000000000", "tokenLogoUrl": "https://xflows.wanchain.org/Token/ETH.png", "tokenName": "ETH", "tokenSymbol": "ETH", "asciiTokenAddress": "0x0000000000000000000000000000000000000000" }, { "decimals": "8", "tokenContractAddress": "0x68f180fcCe6836688e9084f035309E29Bf0A2095", "tokenLogoUrl": "https://xflows.wanchain.org/Token/WBTC.png", "tokenName": "Wrapped BTC", "tokenSymbol": "WBTC", "asciiTokenAddress": "0x68f180fcCe6836688e9084f035309E29Bf0A2095" } ] } ``` -------------------------------- ### Example Cross-Chain Application with Retry Logic (CCPoolV2.sol) Source: https://docs.wanchain.org/products/xport/developer-handbook A practical example demonstrating how to inherit from the RetryableApp contract to build a cross-chain application. This contract showcases on-chain recording of error messages and custom retry rules. ```solidity // Located at: examples/CCPoolV2.sol // Inherits from WmbRetryableApp to implement cross-chain logic with error handling and retries. ``` -------------------------------- ### Wanchain API POST Request Example (WorkMode 1) Source: https://docs.wanchain.org/developers/xflows-api This is an example of a POST request to the Wanchain API's /api/v3/quote endpoint. It demonstrates the required parameters for initiating a cross-chain quote when workMode is set to 1, including chain IDs, token addresses, sender/receiver addresses, and the amount to be transferred. ```json POST https://xflows.wanchain.org/api/v3/quote BODY { "fromChainId": 43114, "toChainId": 56, "fromTokenAddress": "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7", "toTokenAddress": "0x55d398326f99059ff775485246999027b3197955", "fromAddress": "0x2fb4D46372Ea1748ec3c29Bd2C7B536019DF5200", "toAddress": "0x2fb4D46372Ea1748ec3c29Bd2C7B536019DF5200", "fromAmount": "10" } ``` -------------------------------- ### Wanchain API Response Example (WorkMode 1) Source: https://docs.wanchain.org/developers/xflows-api This is an example JSON response from the Wanchain API for a cross-chain quote request with workMode 1. It includes details such as the output amount, slippage, minimum output amount, native and token fees, and additional data related to the direct pair and quota/fee information. ```json { "success": true, "data": { "amountOut": "9.8", "amountOutRaw": "9800000000000000000", "slippage": 0.01, "amountOutMin": "9.8", "amountOutMinRaw": "9800000000000000000", "approvalAddress": "0x88888dd82A91f0406ED42BF750bAF881e64894F6", "priceImpact": 0, "workMode": 1, "bridge": "wanbridge", "nativeFees": [ { "nativeFeeAmount": "6500000000000000", "nativeFeeSymbol": "AVAX", "nativeFeeDecimals": 18 } ], "tokenFees": [ { "tokenFeeAmount": "200000", "tokenFeeSymbol": "USDT", "tokenFeeDecimals": 18, "tokenFeeContract": "0x55d398326f99059ff775485246999027b3197955" } ], "extraData": { "directPair": { "fromChainId": "43114", "toChainId": "56", "fromTokenAddress": "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7", "toTokenAddress": "0x55d398326f99059ff775485246999027b3197955", "fromTokenSymbol": "USDt", "toTokenSymbol": "USDT", "tokenPairId": "235", "symbol": "USDT" }, "quotaAndFee": { "symbol": "USDT", "minQuota": "400000", "maxQuota": "61318064549", "networkFee": { "value": "6500000000000000", "isPercent": false }, "operationFee": { "value": "0.002", "isPercent": true, "minFeeLimit": "200000", "maxFeeLimit": "100000000" } } } } } ``` -------------------------------- ### Initialize Wanchain Validator Environment Source: https://docs.wanchain.org/wanchain-bridge-nodes/deploy-a-bridge-node/how-to-deploy-a-bridge-node-via-wanwallet-desktop-legacy This command downloads the environment setup script from the Wanchain repository, grants it execution permissions, and runs it to configure the validator node. It requires a network connection to fetch the script and will prompt for a validator account password. ```bash wget https://raw.githubusercontent.com/wanchain/two-way-bridge-contracts/master/helpscript/envSetup.sh && chmod +x envSetup.sh && ./envSetup.sh ``` -------------------------------- ### Get Supported Tokens (Specific Chain) Source: https://docs.wanchain.org/developers/xflows-api This snippet shows how to request a list of tokens supported by a specific blockchain network using the `chainId` parameter. The example uses `chainId=10`. ```HTTP GET https://xflows.wanchain.org/api/v3/supported/tokens?chainId=10 ``` -------------------------------- ### Create PoS Account and Show Public Keys (CLI) Source: https://docs.wanchain.org/pos-validator-nodes/common-operations-cli This snippet demonstrates how to create a new Proof-of-Stake (PoS) account using the Wanchain console and how to retrieve the associated public keys. The keystore file is stored locally, and the public keys are necessary for staking registration. ```bash $ gwan console --exec "personal.newAccount('Your Password')" // Or run after ipc attach $ personal.newAccount('Your Password') ``` ```bash $ gwan console --exec "personal.showPublicKey('Your Address', 'Your Password')" // Or run after ipc attach $ personal.showPublicKey('Your Address', 'Your Password') ``` -------------------------------- ### Run Wanchain Testnet RPC Node (Docker) Source: https://docs.wanchain.org/pos-validator-nodes/run-rpc-node-guide Launches a Wanchain testnet RPC node using Docker. Similar to the mainnet Docker command, but includes the `--testnet` flag. Ensures correct port mapping and data persistence. ```bash sudo docker run -d --name wanchain-node -v /home/ubuntu/wanchain:/root -p 8545:8545 -p 17717:17717 wanchain/client-go:3.0.2 gwan --testnet --gcmode=full --http --http.addr 0.0.0.0 --http.port 8545 ``` -------------------------------- ### Untitled Source: https://docs.wanchain.org/pos-validator-nodes/gwan-pos-api No description -------------------------------- ### Execute Delegation Script in GWAN Container Source: https://docs.wanchain.org/pos-validator-nodes/delegation-guide This snippet demonstrates how to access a running GWAN container via Docker, attach to the GWAN IPC, and load a JavaScript script for delegation. It requires a running Docker container with GWAN installed and the delegation script available within the container's filesystem. ```bash $ docker exec -it YourContainerID /bin/bash root> gwan attach .wanchain/gwan.ipc > loadScript("/root/.wanchain/sendDelegate.js") ``` -------------------------------- ### Get Supported Tokens (All Chains) Source: https://docs.wanchain.org/developers/xflows-api This snippet demonstrates how to make a GET request to the XFlows API to retrieve a list of all supported tokens across all chains. No parameters are required for this request. ```HTTP GET https://xflows.wanchain.org/api/v3/supported/tokens ``` -------------------------------- ### Initialize WmbApp in Solidity Smart Contract Constructor Source: https://docs.wanchain.org/products/xport/xport-developer-handbook Illustrates how to call the WmbApp `initialize` function within your smart contract's constructor. The `initialize` function requires the administrator account address and the WmbGateway address as parameters, setting up the necessary configurations for cross-chain operations. ```solidity constructor(address admin, address _wmbGateway) WmbApp() { initialize(admin, _wmbGateway); // Your initialization code } ``` -------------------------------- ### Monitor Wanchain Node Logs Source: https://docs.wanchain.org/pos-validator-nodes/mainnet-node-setup-quick-start Uses Docker to follow the logs of the running 'gwan' container, allowing users to verify successful node startup and chain synchronization. ```bash sudo docker logs -f gwan ``` -------------------------------- ### Example Cross-Chain Token Issuance (mcToken.sol) Source: https://docs.wanchain.org/products/xport/developer-handbook Illustrates the implementation of a cross-chain token issuance mechanism using a burn-and-mint approach. This allows for the creation and transfer of tokens across multiple blockchains without the need for wrapping or liquidity pools. ```solidity // Located at: examples/mcToken.sol // Implements cross-chain token issuance via burn-and-mint. ``` -------------------------------- ### Get Supported Bridges Source: https://docs.wanchain.org/developers/xflows-api Retrieve a list of supported bridges for cross-chain operations. ```APIDOC ## GET /api/v3/supported/bridges ### Description Retrieves a list of supported bridges for cross-chain operations. ### Method GET ### Endpoint https://xflows.wanchain.org/api/v3/supported/bridges ### Parameters No parameters required. ### Response #### Success Response (200) - **data** (array) - A list of supported bridge names. #### Response Example ```json { "data": [ "wanbridge", "quix" ] } ``` ``` -------------------------------- ### Get Supported Chains Source: https://docs.wanchain.org/developers/xflows-api Retrieve a list of supported chains for cross-chain operations. ```APIDOC ## GET /api/v3/supported/chains ### Description Retrieves a list of supported chains for cross-chain operations. ### Method GET ### Endpoint https://xflows.wanchain.org/api/v3/supported/chains ### Parameters No parameters required. ### Response #### Success Response (200) - **data** (array) - A list of supported chain objects. - **chainId** (integer) - The ID of the chain. - **name** (string) - The name of the chain. - **nativeToken** (string) - The native token symbol of the chain. #### Response Example ```json { "data": [ { "chainId": 1, "name": "Ethereum", "nativeToken": "ETH" }, { "chainId": 56, "name": "BNB Smart Chain", "nativeToken": "BNB" } ] } ``` ``` -------------------------------- ### Query Foundation Whitelist Configuration Source: https://docs.wanchain.org/pos-validator-nodes/gwan-pos-api Retrieves configuration and public key lists for Wanchain Foundation controlled nodes for specific epochs. ```javascript > pos.getWhiteListConfig() [{ EpochId: 0, WlCount: 26, WlIndex: 0 }] > pos.getWhiteListbyEpochID(18108) ["0x0451cffffa2fb947261efca509564768d909a4fefd450c0e00effc8d7cb848dbd08939e163a6a41bde571f4ae0056b876c2b01c18e1e2d6b7a4745b49f5f5912c0", ...] ``` -------------------------------- ### Get Supported DEXes Source: https://docs.wanchain.org/developers/xflows-api Retrieve a list of supported decentralized exchanges (DEXes) for cross-chain operations. ```APIDOC ## GET /api/v3/supported/dexes ### Description Retrieves a list of supported decentralized exchanges (DEXes) for cross-chain operations. ### Method GET ### Endpoint https://xflows.wanchain.org/api/v3/supported/dexes ### Parameters No parameters required. ### Response #### Success Response (200) - **data** (array) - A list of supported DEX names. #### Response Example ```json { "data": [ "wanchain", "rubic" ] } ``` ``` -------------------------------- ### Get Supported Tokens Source: https://docs.wanchain.org/developers/xflows-api Retrieve a list of supported tokens for cross-chain operations on a specific chain. ```APIDOC ## GET /api/v3/supported/tokens ### Description Retrieves a list of supported tokens for cross-chain operations on a specific chain. ### Method GET ### Endpoint https://xflows.wanchain.org/api/v3/supported/tokens ### Parameters #### Query Parameters - **chainId** (integer) - Required - The ID of the chain for which to retrieve supported tokens. ### Response #### Success Response (200) - **data** (array) - A list of supported token objects. - **tokenAddress** (string) - The WanBridge-encoded token contract address. - **symbol** (string) - The token symbol. - **decimals** (integer) - The number of decimals for the token. #### Response Example ```json { "data": [ { "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "symbol": "WETH", "decimals": 18 }, { "tokenAddress": "0x1111111111111111111111111111111111111111", "symbol": "WBNB", "decimals": 18 } ] } ``` ```