### Install Node.js, web3.js, and ethereumjs-util.js Source: https://docs.wemix.com/en/tutorial/use-fee-delegation Before using the fee delegation modules, ensure Node.js is installed and then install the required JavaScript libraries using npm. ```bash npm install web3; npm install ethereumjs-util; ``` -------------------------------- ### Dynamic Documentation Query Example Source: https://docs.wemix.com/en/dapp-developer/api-reference/event-logs-apis To get additional information not explicitly present on the page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://docs.wemix.com/en/dapp-developer/api-reference/event-logs-apis.md?ask= ``` -------------------------------- ### Install Truffle Source: https://docs.wemix.com/en/dapp-developer/smart-contract/sample-contracts Install Truffle globally using NPM. Ensure Node.js and NPM are installed. ```bash $ npm install --g truffle ``` -------------------------------- ### Start gwemix Node Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Executes the start script for the WEMIX node. Ensure the GWEMIX_HOME environment variable is set correctly. ```bash $GWEMIX_HOME/bin/gwemix.sh start ``` -------------------------------- ### Install Build Dependencies (Ubuntu 22.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Installs essential build tools and Go for compiling the WEMIX node on Ubuntu 22.04 LTS. ```bash sudo apt-get update sudo apt-get install -y build-essential golang ``` -------------------------------- ### Create and Initialize Hardhat Project Source: https://docs.wemix.com/en/tutorial/create-smart-contract/hardhat Steps to create a new directory, install Hardhat, and initialize a new project using the Hardhat command-line interface. This includes selecting project type and installing dependencies. ```bash $ mkdir greeter $ cd greeter $ npm install --save-dev hardhat $ npx hardhat 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888 888 888 "88b 888P" d88" 888 888 "88b "88b 888 888 888 .d888888 888 888 888 888 888 .d888888 888 888 888 888 888 888 Y88b 888 888 888 888 888 Y88b. 888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888 👷 Welcome to Hardhat v2.13.0 👷‍ ✔ What do you want to do? · Create a JavaScript project ✔ Hardhat project root: · /Users/trident/Projects/Solidity/hardhat-test ✔ Do you want to add a .gitignore? (Y/n) · y ✔ Do you want to install this sample project's dependencies with npm (hardhat @nomicfoundation/hardhat-toolbox)? (Y/n) · y ``` -------------------------------- ### Install Go Version 1.18.4 (Ubuntu 20.04/18.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Downloads, installs, and configures Go version 1.18.4, which is required for building the WEMIX node on specific Ubuntu versions. ```bash wget https://go.dev/dl/go1.18.4.linux-amd64.tar.gz sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.18.4.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin source $HOME/.profile ``` -------------------------------- ### Start WEMIX3.0 Node Source: https://docs.wemix.com/en/install-and-operation/operation-guide Use this command to start the built 'gwemix' node using the 'gwemix.sh' script. Log files are automatically saved in the '{data_folder}/log' directory. ```bash {data_directory}/bin/gwemix.sh start ``` -------------------------------- ### Install Build Dependencies (Ubuntu 20.04/18.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Installs essential build tools for compiling the WEMIX node on older Ubuntu LTS versions. ```bash sudo apt-get update sudo apt-get install -y build-essential ``` -------------------------------- ### Example: Execute Total Supply API (Testnet) Source: https://docs.wemix.com/en/tutorial/erc-20-token/check-erc-20-token-api This is an example of a Testnet ERC-20 token total supply API query. It demonstrates how to format the URI with a specific contract address. ```HTTP https://explorerapi.test.wemix.com/v1/tokens/0x316E2e2DB3fb28e663F2F59899f98D5b925F7E53/total-supply ``` -------------------------------- ### Mint Tokens Example Source: https://docs.wemix.com/en/dapp-developer/api-reference/contract-apis Example of minting tokens. This example mints 100 tokens to the message sender. ```Solidity // Mint 100 tokens to msg.sender // Similar to how // 1 dollar = 100 cents // 1 token = 1 * (10 ** decimals) _mint(msg.sender, 99999999 * 10**uint(decimals())); ``` -------------------------------- ### Burn Tokens Example Source: https://docs.wemix.com/en/dapp-developer/api-reference/contract-apis Example of burning tokens. This example burns a specified amount of tokens from an account. ```Solidity function burn(address account, uint256 amount) public virtual returns (bool) { _burn(account, amount * 10**uint(decimals())); return true; } ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.wemix.com/en/tutorial/create-smart-contract To get additional information not directly available on a page, perform an HTTP GET request to the current page URL with the 'ask' query parameter. The question should be specific and in natural language. ```bash GET https://docs.wemix.com/en/tutorial/create-smart-contract.md?ask= ``` -------------------------------- ### Example Token Name and Symbol Source: https://docs.wemix.com/en/tutorial/erc-721-token/write-erc-721-contract This example demonstrates how to set the token name to 'WMNFT' and the symbol to 'NFT' within the ERC-721 contract's constructor. ```solidity constructor() public ERC721("WMNFT", "NFT") {} ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.wemix.com/en/tutorial/create-smart-contract/hardhat Perform an HTTP GET request on a documentation URL with the 'ask' query parameter to ask a question. The response will contain a direct answer and relevant excerpts. ```http GET https://docs.wemix.com/en/tutorial/create-smart-contract/hardhat.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.wemix.com/en/install-and-operation Use this method to dynamically query the documentation by asking a question. Perform an HTTP GET request on the current page URL with the 'ask' query parameter. ```HTTP GET https://docs.wemix.com/en/install-and-operation.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.wemix.com/en/quick-start/start-node/use-binary/command-line-option To get more information not present on the current page, make an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and in natural language. ```bash GET https://docs.wemix.com/en/quick-start/start-node/use-binary/command-line-option.md?ask= ``` -------------------------------- ### Connect via RPC Source: https://docs.wemix.com/en/quick-start/connect-node Use this command to connect to the locally installed gwemix RPC web server. ```bash gwemix attach rpc:http://localhost:8588 ``` -------------------------------- ### Connect via IPC Source: https://docs.wemix.com/en/quick-start/connect-node Use this command to connect to the locally installed gwemix IPC file. ```bash gwemix attach {data_folder}/gwemix.ipc ``` -------------------------------- ### Request Sample for Mined Blocks by Address Source: https://docs.wemix.com/en/dapp-developer/api-reference/account-apis Example of a GET request to retrieve blocks mined by a specific address. Includes the API endpoint and an example API key. ```http GET https://explorerapi.test.wemix.com/v1/accounts/0xf04f49b134996023e980022502581c7278f3191a/mined-blocks api-key: 1ba5e446edf1997f67b51bf9e60b3fbba6fa1bf84301115292805d7e24f43539 ``` -------------------------------- ### Counter Smart Contract Example Source: https://docs.wemix.com/en/dapp-developer/smart-contract/sample-contracts A simple Solidity contract demonstrating increment, decrement, and get functions for a counter variable. ```solidity pragma solidity ^0.8.0; contract Counter { uint256 count; constructor(uint256 _count) { count = _count; } function get() public view returns (uint256) { return count; } function inc() public { count += 1; } function dec() public { count -= 1; } } ``` -------------------------------- ### Install gwemix Binary (Ubuntu 22.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Copies the compiled gwemix binary and associated scripts to the specified GWEMIX_HOME directory and extracts the archive. ```bash GWEMIX_HOME='/opt/gwemix' sudo mkdir -p $GWEMIX_HOME sudo chown $USER:$USER $GWEMIX_HOME cp build/gwemix.tar.gz $GWEMIX_HOME/ cd $GWEMIX_HOME tar xvzf gwemix.tar.gz ``` -------------------------------- ### Querying Documentation with Remix Source: https://docs.wemix.com/en/tutorial/create-smart-contract/remix Demonstrates how to dynamically query documentation for additional information using an HTTP GET request with the 'ask' query parameter. ```http GET https://docs.wemix.com/en/tutorial/create-smart-contract/remix.md?ask= ``` -------------------------------- ### Simple Counter Smart Contract Source: https://docs.wemix.com/en/dapp-developer/smart-contract/solidity A basic Solidity contract demonstrating state variables, a constructor, and functions to get, increment, and decrement a counter. Use this as a starting point for simple state management contracts. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.11; contract Counter { uint256 count; constructor(uint256 _count) { count = _count; } function get() public view returns (uint256) { return count; } function inc() public { count += 1; } function dec() public { count -= 1; } } ``` -------------------------------- ### Import an External WEMIX3.0 Account Source: https://docs.wemix.com/en/quick-start/account Prepare the keystore directory and copy your external account file into it to import the account. Ensure the keystore directory has restricted permissions. ```bash mkdir {data_directory}/keystore chmod 700 {data_directory}/keystore cp {data_directory}/keystore ``` -------------------------------- ### Ask a Question via GET Request Source: https://docs.wemix.com/en Perform an HTTP GET request to the documentation index with the 'ask' parameter to get a specific answer to a question. The question should be self-contained and in natural language. ```http GET https://docs.wemix.com/about.md?ask= ``` -------------------------------- ### Initialize Truffle Project Source: https://docs.wemix.com/en/dapp-developer/smart-contract/sample-contracts Initialize a new Truffle project. This creates a standard project structure including contracts, migrations, and test directories. ```bash $ truffle init ``` -------------------------------- ### Install Rocksdb Dependency for Ubuntu Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Installs the libjemalloc1 package required for Rocksdb on Ubuntu 18.04 LTS. This is a prerequisite for certain configurations. ```bash sudo apt-get isntall libjemalloc1 ``` -------------------------------- ### Node Settings Configuration Source: https://docs.wemix.com/en/quick-start/connect-node Configure node execution options by creating a .rc file in the data folder. This example shows how to set the port, enable discovery mode, use Testnet, set sync mode, and add custom options. ```bash PORT=8588 DISCOVER=1 # 1 for enable discovery mode, 0 for disable discovery mode TESTNET=1 # 1 for Testnet or remove this line for Mainnet SYNC_MODE=full GWEMIX_OPTS="--rpc.allow-unprotected-txs" ``` -------------------------------- ### Truffle Migration with Network Configuration Source: https://docs.wemix.com/en/dapp-developer/smart-contract/sample-contracts Example output of running a Truffle migration on the WEMIX Testnet, including compilation status, network details, and deployment costs for initial and contract migrations. ```bash ❯ truffle migrate --reset --network wemix_testnet Compiling your contracts... =========================== > Everything is up to date, there is nothing to compile. Starting migrations... ====================== > Network name: 'wemix_testnet' > Network id: 1112 > Block gas limit: 105000000 (0x6422c40) 1_initial_migration.js ====================== Replacing 'Migrations' ---------------------- > transaction hash: 0x8f57dc573afbf1e33b75b2f05282aac9152be70cee292c31c94877397cf27d82 > Blocks: 0 Seconds: 0 > contract address: 0x09C38aaf3AF7Dba9Cc2B755d75Acccf4A5b7bECC > block number: 428504 > block timestamp: 1658480854 > account: 0x435AaB89A2878102fDf894dA3e5F3b4454FF9772 > balance: 9.926666599999266666 > gas used: 250142 (0x3d11e) > gas price: 100.000000001 gwei > value sent: 0 ETH > total cost: 0.025014200000250142 ETH > Saving migration to chain. > Saving artifacts ------------------------------------- > Total cost: 0.025014200000250142 ETH 2_deploy_contracts.js ===================== Deploying 'Counter' ------------------- > transaction hash: 0x893fcc06e298b95ff145c90311c5d36a3f8c511470e73a753d13195ea9dae051 > Blocks: 0 Seconds: 0 > contract address: 0x76F3A4DFD8741E765Bf27Cd0BaaE26f64c192765 > block number: 428508 > block timestamp: 1658480857 > account: 0x435AaB89A2878102fDf894dA3e5F3b4454FF9772 > balance: 9.904089499999040895 > gas used: 179858 (0x2be92) > gas price: 100.000000001 gwei > value sent: 0 ETH > total cost: 0.017985800000179858 ETH > Saving migration to chain. > Saving artifacts ------------------------------------- > Total cost: 0.017985800000179858 ETH Summary ======= > Total deployments: 2 > Final cost: 0.04300000000043 ETH ``` -------------------------------- ### Execute Fee Delegation Sample Code Source: https://docs.wemix.com/en/tutorial/use-fee-delegation Run the provided JavaScript sample code using Node.js to perform fee delegation transactions. Ensure the utility files and sample code are in the same directory. ```bash $ node FeeDelegateSampleCode.js ``` -------------------------------- ### Example: Check Testnet ERC-721 Token Inventory Source: https://docs.wemix.com/en/tutorial/erc-721-token/check-erc-721-token-api An example of a complete URI to check the inventory for a specific ERC-721 token contract address on the WEMIX3.0 Testnet. ```HTTP https://explorerapi.test.wemix.com/v1/tokens/0x3DDeE3714160A49573285473f40452cec67114B4/inventory ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.wemix.com/en/tutorial/erc-721-token/check-erc-721-token-api Demonstrates how to query the documentation dynamically by appending an 'ask' parameter with a natural language question to the page URL. ```HTTP GET https://docs.wemix.com/en/tutorial/erc-721-token/check-erc-721-token-api.md?ask= ``` -------------------------------- ### GET Account Transactions Sample Request Source: https://docs.wemix.com/en/dapp-developer/api-reference/account-apis This sample demonstrates how to retrieve transactions for a specific account using the GET method. Ensure you include the 'api-key' in the header. ```http GET https://explorerapi.wemix.com/v1/accounts/0xBbAB376Fd9c3a0f5ef1D2114c8dd1512FD858ee2/transactions api-key: 1ba5e446edf1997f67b51bf9e60b3fbba6fa1bf84301115292805d7e24f43539 ``` -------------------------------- ### Install RocksDB Dependencies (Ubuntu 22.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Installs RocksDB specific dependencies required for building the WEMIX node with RocksDB support on Ubuntu 22.04 LTS. ```bash sudo apt-get install -y snappy-dev libjemalloc-dev cd /usr/lib/x86_64-linux-gnu/ sudo ln -sf libjemalloc.so.2 libjemalloc.so.1 ``` -------------------------------- ### Create .rc Configuration File Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Sets up the configuration parameters for the Wemix node, including port, discovery mode, network type (Testnet/Mainnet), sync mode, and additional options. Adjust TESTNET to 1 for Testnet or remove the line for Mainnet. ```bash PORT=8588 DISCOVER=1 # 1 for enable discovery mode, 0 for disable discovery mode TESTNET=1 # 1 for Testnet or remove this line for Mainnet SYNC_MODE=full GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100" ``` -------------------------------- ### Configure gwemix Node (.rc file) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Creates or updates the .rc file in GWEMIX_HOME with essential configuration parameters for the WEMIX node. ```bash PORT=8588 DISCOVER=1 # 1 for enable discovery mode, 0 for disable discovery mode TESTNET=1 # 1 for Testnet or remove this line for Mainnet SYNC_MODE=full GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100" ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.wemix.com/en/tutorial/erc-20-token Perform an HTTP GET request to query documentation dynamically. Use this when the answer is not explicitly present, for clarification, or to retrieve related sections. ```HTTP GET https://docs.wemix.com/en/tutorial/erc-20-token.md?ask= ``` -------------------------------- ### Install RocksDB Dependencies (Ubuntu 20.04/18.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Installs RocksDB specific dependencies required for building the WEMIX node with RocksDB support on older Ubuntu LTS versions. ```bash sudo apt-get install -y libsnappy-dev libjemalloc-dev cd /usr/lib/x86_64-linux-gnu/ sudo ln -sf libjemalloc.so.2 libjemalloc.so.1 ``` -------------------------------- ### Build gwemix with LevelDB (Ubuntu 22.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Compiles the gwemix binary using LevelDB as the database backend. Set USE_ROCKSDB=NO to disable RocksDB. ```bash make USE_ROCKSDB=NO ``` -------------------------------- ### GET Request for ERC721 Token Transfers Source: https://docs.wemix.com/en/dapp-developer/api-reference/account-apis This snippet shows a sample GET request to retrieve ERC721 token transfer history for a specific account. Ensure you include the 'api-key' in the header. ```http GET https://explorerapi.test.wemix.com/v1/accounts/0x43dc58449beb06bf350e0181703c617f0bfa78bf/token-transfer/erc721 api-key: 1ba5e446edf1997f67b51bf9e60b3fbba6fa1bf84301115292805d7e24f43539 ``` -------------------------------- ### Create a Simple Contract Template Source: https://docs.wemix.com/en/tutorial/create-smart-contract/truffle Use the 'truffle create contract' command to generate a basic smart contract file. This is a starting point for your contract logic. ```solidity // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Greeter { constructor() public { } } ``` -------------------------------- ### Deploy Smart Contract with Hardhat Source: https://docs.wemix.com/en/tutorial/create-smart-contract/hardhat This script compiles your smart contract, deploys it with specified parameters, and logs the contract address. Ensure you have the Hardhat environment set up. ```javascript const hre = require("hardhat"); async function main() { const currentTimestampInSeconds = Math.round(Date.now() / 1000); const unlockTime = currentTimestampInSeconds + 60; const lockedAmount = hre.ethers.utils.parseEther("0.001"); const Lock = await hre.ethers.getContractFactory("Lock"); const lock = await Lock.deploy(unlockTime, { value: lockedAmount }); await lock.deployed(); console.log( `Lock with ${ethers.utils.formatEther( lockedAmount )}ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}` ); } // We recommend this pattern to be able to use async/await everywhere // and properly handle errors. main().catch((error) => { console.error(error); process.exitCode = 1; }); ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.wemix.com/en/dapp-developer/json-rpc To get more information not directly available on the page, make an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.wemix.com/en/dapp-developer/json-rpc.md?ask= ``` -------------------------------- ### Define Greeter Contract with Constructor and Methods Source: https://docs.wemix.com/en/tutorial/create-smart-contract/truffle This is an example of a 'Greeter' smart contract that accepts an initial greeting in its constructor and provides methods to retrieve and set the greeting. ```solidity // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Greeter { string private greeting; constructor(string memory _greeting) public { greeting = _greeting; } function greet() public view returns (string memory) { return greeting; } function setGreeting(string memory _greeting) public { greeting = _greeting; } } ``` -------------------------------- ### Build gwemix with RocksDB (Ubuntu 22.04 LTS) Source: https://docs.wemix.com/en/install-and-operation/block-producer-node/install-guide Compiles the gwemix binary using RocksDB as the database backend. Ensure RocksDB dependencies are installed. ```bash make ``` -------------------------------- ### Query Documentation with `ask` Parameter Source: https://docs.wemix.com/en/dapp-developer/api-reference To get specific information not directly on a page, perform an HTTP GET request to the page URL with the `ask` query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.wemix.com/en/dapp-developer/api-reference.md?ask= ```