### Installation Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Provides the command to install the go-metrics library using the Go toolchain. ```sh go get github.com/rcrowley/go-metrics ``` -------------------------------- ### Build and Install Theta Binaries Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/README.md Enables Go modules and builds the Theta node (`theta`) and command-line interface (`thetacli`) binaries. These are essential for running and interacting with the Theta Ledger. ```bash export GO111MODULE=on make install ``` -------------------------------- ### Theta Local Test Environment Setup Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/README.md Guides users on setting up a local test environment for the Theta blockchain. This includes launching a private network, using command-line tools, and connecting to testnet/mainnet. ```APIDOC Local Test Environment: - Launching a local privatenet: https://docs.thetatoken.org/docs/launch-a-local-privatenet - Command line tools: https://docs.thetatoken.org/docs/command-line-tool - Connecting to Testnet: https://docs.thetatoken.org/docs/connect-to-the-testnet - Connecting to Mainnet: https://docs.thetatoken.org/docs/connect-to-the-mainnet - Node configuration: https://docs.thetatoken.org/docs/theta-blockchain-node-configuration ``` -------------------------------- ### StatHat Support Installation Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Details the additional command required to install the StatHat Go client, which is a dependency for StatHat metric reporting. ```sh go get github.com/stathat/go ``` -------------------------------- ### FreeBSD Prerequisites Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Installs required packages on FreeBSD, such as GNU make, libiconv, and Fox-Toolkit. Includes steps for installing Autotools when cloning from a git repository. ```bash pkg_add -r gmake libiconv fox16 pkg_add -r autotools ``` -------------------------------- ### Install Go on macOS Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/README.md Installs Go version 1.14.1 on macOS using Homebrew and forces the link to make it the active version. This is a prerequisite for building the Theta protocol. ```bash brew install go@1.14.1 brew link go@1.14.1 --force ``` -------------------------------- ### Install go-flowrate Package Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/p2pl/transport/buffer/flowrate/README.md This snippet shows the command to download and install the go-flowrate package using the Go module system. It fetches the latest version of the library. ```go go get github.com/mxk/go-flowrate/flowrate ``` -------------------------------- ### Build and Installation Steps Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/crypto/secp256k1/libsecp256k1/README.md Steps to build, test, and optionally install the libsecp256k1 library using autotools. This process involves generating build scripts, configuring the build, compiling the library, running tests, and installing the library to the system. ```bash ./autogen.sh ``` ```bash ./configure ``` ```bash make ``` ```bash ./tests ``` ```bash sudo make install ``` -------------------------------- ### macOS Prerequisites (Fox-Toolkit) Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Instructions for installing Fox-Toolkit on macOS. The 'ports' method is suitable for personal testing, while manual installation from source is required for redistributable app bundles due to X11 library compatibility. ```bash sudo port install fox # For manual install from source: # ./configure && make && make install ``` -------------------------------- ### Install go-flowrate Package Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/p2p/connection/flowrate/README.md This snippet shows the command to download and install the go-flowrate package using the Go module system. It fetches the latest version of the library. ```go go get github.com/mxk/go-flowrate/flowrate ``` -------------------------------- ### Install jsonrpc2 Go Package Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/rpc/lib/rpc-codec/README.md Command to install the jsonrpc2 Go package using go get. ```sh go get github.com/powerman/rpc-codec/... ``` -------------------------------- ### Basic HID Device Interaction Example Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Demonstrates the fundamental usage of the HIDAPI library, including initialization, opening a device by VID/PID, reading device strings (manufacturer, product, serial), sending a command to toggle an LED, requesting device state, reading the state, and finalization. ```c #ifdef WIN32 #include #endif #include #include #include "hidapi.h" #define MAX_STR 255 int main(int argc, char* argv[]) { int res; unsigned char buf[65]; wchar_t wstr[MAX_STR]; hid_device *handle; int i; // Initialize the hidapi library res = hid_init(); // Open the device using the VID, PID, // and optionally the Serial number. handle = hid_open(0x4d8, 0x3f, NULL); // Read the Manufacturer String res = hid_get_manufacturer_string(handle, wstr, MAX_STR); wprintf(L"Manufacturer String: %s\n", wstr); // Read the Product String res = hid_get_product_string(handle, wstr, MAX_STR); wprintf(L"Product String: %s\n", wstr); // Read the Serial Number String res = hid_get_serial_number_string(handle, wstr, MAX_STR); wprintf(L"Serial Number String: (%d) %s\n", wstr[0], wstr); // Read Indexed String 1 res = hid_get_indexed_string(handle, 1, wstr, MAX_STR); wprintf(L"Indexed String 1: %s\n", wstr); // Toggle LED (cmd 0x80). The first byte is the report number (0x0). buf[0] = 0x0; buf[1] = 0x80; res = hid_write(handle, buf, 65); // Request state (cmd 0x81). The first byte is the report number (0x0). buf[0] = 0x0; buf[1] = 0x81; res = hid_write(handle, buf, 65); // Read requested state res = hid_read(handle, buf, 65); // Print out the returned buffer. for (i = 0; i < 4; i++) printf("buf[%d]: %d\n", i, buf[i]); // Finalize the hidapi library res = hid_exit(); return 0; } ``` -------------------------------- ### Start Theta CLI Daemon Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_daemon_start.md Starts the Theta CLI daemon. This command allows you to run the daemon with specific configurations, such as setting the port. It includes options for help, port configuration, and inherited configuration paths. ```APIDOC Command: thetacli daemon start Description: Run the Theta CLI daemon. Synopsis: thetacli daemon start [flags] Examples: thetacli daemon start --port=16889 Options: -h, --help help for start --port string Port to run the ThetaCli Daemon (default "16889") Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") SEE ALSO: * thetacli daemon - Run the ThetaCli Daemon ``` -------------------------------- ### Linux Prerequisites Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Installs necessary development packages for HIDAPI on Debian/Ubuntu systems, including libudev, libusb, and Fox-toolkit. Also includes steps for installing Autotools if building from a git repository. ```bash sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev sudo apt-get install autotools-dev autoconf automake libtool ``` -------------------------------- ### Clone Theta Repo and Set Environment Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/README.md Clones the Theta protocol repository into the Go workspace and sets the THETA_HOME environment variable. This prepares the development environment for building. ```bash git clone https://github.com/thetatoken/theta-protocol-ledger.git $GOPATH/src/github.com/thetatoken/theta export THETA_HOME=$GOPATH/src/github.com/thetatoken/theta cd $THETA_HOME ``` -------------------------------- ### Run Unit Tests Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/README.md Executes all unit tests for the Theta protocol codebase. This command verifies the integrity and correctness of individual components. ```bash make test_unit ``` -------------------------------- ### HIDAPI Autotools Configuration Options Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Common arguments for the './configure' script used in building HIDAPI. These options control features like enabling the test GUI and specifying the installation prefix. ```APIDOC configure options: --enable-testgui Enable build of the Test GUI. Requires Fox toolkit to be installed. --prefix=/usr Specify where to install output headers and libraries. Defaults to /usr/local. ``` -------------------------------- ### Theta Start Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/ledger/theta_start.md Starts the Theta node. This command is used to initiate the Theta network client, with various options available for configuration and control. ```APIDOC Theta Start Command: Starts Theta node. Synopsis: theta start [flags] Options: -h, --help help for start Options inherited from parent commands: --config string config path (default is /Users//.theta) (default "/Users//.theta") --snapshot string snapshot path SEE ALSO: * [theta](theta.md) - Theta ###### Auto generated by spf13/cobra on 24-Apr-2019 ``` -------------------------------- ### Building HIDAPI Shared Library (Unix/Autotools) Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Standard procedure for building HIDAPI as a shared library on Unix-like systems using Autotools. This involves bootstrapping, configuring, compiling, and installing the library. ```bash ./bootstrap ./configure make make install ``` -------------------------------- ### Create and Register Metrics Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Demonstrates how to create and register different types of metrics (Counter, Gauge, Histogram, Meter, Timer) with a registry. Includes examples for functional gauges and different sample implementations for histograms. ```go c := metrics.NewCounter() metrics.Register("foo", c) c.Inc(47) g := metrics.NewGauge() metrics.Register("bar", g) g.Update(47) r := metrics.NewRegistry() g := metrics.NewRegisteredFunctionalGauge("cache-evictions", r, func() int64 { return cache.getEvictionsCount() }) s := metrics.NewExpDecaySample(1028, 0.015) // or metrics.NewUniformSample(1028) h := metrics.NewHistogram(s) metrics.Register("baz", h) h.Update(47) m := metrics.NewMeter() metrics.Register("quux", m) m.Mark(47) t := metrics.NewTimer() metrics.Register("bang", t) t.Time(func() {}) // Measure execution time of a function t.Update(47) // Update with a duration ``` -------------------------------- ### Cross-Compile Windows Binary from macOS Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/README.md Cross-compiles the Windows binary for the Theta Ledger from a macOS environment using `mingw64`. It also notes the requirement to place specific DLL files alongside the executable. ```bash make exe ``` -------------------------------- ### Launch Theta Privatenet with 4 Validators Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/integration/testnet/README.md This snippet provides the shell commands necessary to launch a local Theta privatenet. It includes setting up the testnet directory, creating a logs directory, and starting four validator nodes, each logging its output to a separate file. ```shell cd $THETA_HOME cp -r ./integration/testnet ../testnet mkdir ../testnet/logs # In terminal 1 theta start --config=../testnet/node1 |& tee ../testnet/logs/node1.log # In terminal 2 theta start --config=../testnet/node2 |& tee ../testnet/logs/node2.log # In terminal 3 theta start --config=../testnet/node3 |& tee ../testnet/logs/node3.log # In terminal 4 theta start --config=../testnet/node4 |& tee ../testnet/logs/node4.log ``` -------------------------------- ### thetacli tx smart_contract Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_tx_smart_contract.md This entry details the usage, parameters, and examples for the `thetacli tx smart_contract` command, which is used for deploying and calling smart contracts on the Theta network. ```APIDOC thetacli tx smart_contract [flags] Description: Submits a smart contract transaction to the blockchain, which will modify the global consensus state when it is included in the blockchain. Synopsis: thetacli tx smart_contract [flags] Examples: [Deploy a smart contract] thetacli tx smart_contract --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --value=1680 --gas_price=3 --gas_limit=50000 --data=600a600c600039600a6000f3600360135360016013f3 --seq=1 [Call an API of a smart contract] thetacli tx smart_contract --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=0x7ad6cea2bc3162e30a3c98d84f821b3233c22647 --gas_price=3 --gas_limit=50000 --seq=2 Options: --chain string Chain ID --data string The data for the smart contract --from string The caller address --gas_limit uint The gas limit --gas_price string The gas price (default "100000000wei") -h, --help help for smart_contract --seq uint Sequence number of the transaction --to string The smart contract address --value string Value to be transferred (default "0") --wallet string Wallet type (soft|nano) (default "soft") Inherited Options: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") Related Commands: thetacli tx ``` -------------------------------- ### thetacli backup snapshot Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_backup_snapshot.md This section details the 'thetacli backup snapshot' command. It covers the command's synopsis, available flags, inherited options like the configuration path, and usage examples. This command is used for managing backups within the theta-protocol-ledger. ```cli thetacli backup snapshot [flags] ``` ```cli thetacli backup snapshot ``` ```cli -h, --help help for snapshot ``` ```cli --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") ``` -------------------------------- ### Theta Blockchain Smart Contract Development Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/README.md Provides links and guidance for developing smart contracts and DApps on the Theta blockchain. It highlights EVM compatibility and integration with popular development tools. ```APIDOC Smart Contract Development Overview: - Link: https://docs.thetatoken.org/docs/turing-complete-smart-contract-support Tutorials for Interaction: - Metamask: https://docs.thetatoken.org/docs/web3-stack-metamask - Truffle: https://docs.thetatoken.org/docs/web3-stack-truffle - Hardhat: https://docs.thetatoken.org/docs/web3-stack-hardhat - web3.js: https://docs.thetatoken.org/docs/web3-stack-web3js - ethers.js: https://docs.thetatoken.org/docs/web3-stack-ethersjs TNT20 Token Integration: - Guide: https://docs.thetatoken.org/docs/theta-blockchain-tnt20-token-integration-guide ``` -------------------------------- ### thetacli tx deposit Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_tx_deposit.md Details the 'thetacli tx deposit' command for depositing stake to a validator or guardian. Covers synopsis, parameters, and usage examples. ```APIDOC Command: thetacli tx deposit Description: Deposit stake to a validator or guardian Synopsis: thetacli tx deposit [flags] Examples: thetacli tx deposit --chain="privatenet" --source=2E833968E5bB786Ae419c4d13189fB081Cc43bab --holder=2E833968E5bB786Ae419c4d13189fB081Cc43bab --stake=6000000 --purpose=0 --seq=7 Options: --chain string Chain ID --fee string Fee (default "1000000000000wei") -h, --help help for deposit --holder string Holder of the stake --purpose uint8 Purpose of staking --seq uint Sequence number of the transaction --source string Source of the stake --stake string Theta amount to stake (default "5000000") --wallet string Wallet type (soft|nano) (default "soft") Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") SEE ALSO: * thetacli tx: Manage transactions ``` -------------------------------- ### thetacli query vcp Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_query_vcp.md Details the `thetacli query vcp` command for retrieving the validator candidate pool. It covers the command's synopsis, usage examples, and available options, including inherited flags. ```APIDOC thetacli query vcp Synopsis: thetacli query vcp [flags] Description: Get validator candidate pool Examples: thetacli query vcp --height=10 Options: --height uint height of the block -h, --help help for vcp Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") SEE ALSO: * [thetacli query](thetacli_query.md) - Query entities stored in blockchain ###### Auto generated by spf13/cobra on 24-Apr-2019 ``` -------------------------------- ### thetacli query tx - Get Transaction Details Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_query_tx.md Retrieves details of a specific transaction using its hash. This command requires the transaction hash as input and can accept global flags for configuration. ```CLI thetacli query tx [flags] ``` ```CLI thetacli query tx --hash=0x2fe41732b40ca852e9c36f52b278dde78f0fe34f28f9c94083112aa6a0624b8c ``` ```CLI --hash string Block hash -h, --help help for tx ``` ```CLI --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") ``` -------------------------------- ### Configure Hardhat for Theta Private Network Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/integration/privatenet/node_eth_rpc/README.md Modify your `hardhat.config.js` to include the Theta private network configuration. This setup specifies the RPC endpoint, test accounts, chain ID, and gas price for testing purposes. ```javascript module.exports = { ... mocha: { timeout: 1000000000, }, networks: { ... theta_privatenet: { url: "http://localhost:18888/rpc", accounts: [ "1111111111111111111111111111111111111111111111111111111111111111", // 0x19E7E376E7C213B7E7e7e46cc70A5dD086DAff2A "2222222222222222222222222222222222222222222222222222222222222222", // 0x1563915e194D8CfBA1943570603F7606A3115508 "3333333333333333333333333333333333333333333333333333333333333333", // 0x5CbDd86a2FA8Dc4bDdd8a8f69dBa48572EeC07FB "4444444444444444444444444444444444444444444444444444444444444444", // 0x7564105E977516C53bE337314c7E53838967bDaC "5555555555555555555555555555555555555555555555555555555555555555", // 0xe1fAE9b4fAB2F5726677ECfA912d96b0B683e6a9 "6666666666666666666666666666666666666666666666666666666666666666", // 0xdb2430B4e9AC14be6554d3942822BE74811A1AF9 "7777777777777777777777777777777777777777777777777777777777777777", // 0xAe72A48c1a36bd18Af168541c53037965d26e4A8 "8888888888888888888888888888888888888888888888888888888888888888", // 0x62f94E9AC9349BCCC61Bfe66ddAdE6292702EcB6 "9999999999999999999999999999999999999999999999999999999999999999", // 0x0D8e461687b7D06f86EC348E0c270b0F279855F0 "1000000000000000000000000000000000000000000000000000000000000000", // 0x7B2419E0Ee0BD034F7Bf24874C12512AcAC6e21C ], chainId: 366, gasPrice: 4000000000000, }, ... }, ... } ``` -------------------------------- ### thetacli tx reserve Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_tx_reserve.md This section documents the `thetacli tx reserve` command, which is used to reserve funds for off-chain micropayments. It includes the command's synopsis, available options with their types and default values, and a practical usage example. ```APIDOC thetacli tx reserve: Reserve fund for an off-chain micropayment Synopsis: thetacli tx reserve [flags] Description: Reserves fund for an off-chain micropayment. Examples: thetacli tx reserve --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --fund=900 --collateral=1203 --seq=6 --duration=1002 --resource_ids=die_another_day,hello Options: --chain string Chain ID --collateral string TFuel amount as collateral (default "0") --duration uint Reserve duration (default 1000) --fee string Fee (default "1000000000000wei") --from string Address to send from --fund string TFuel amount to reserve (default "0") -h, --help help for reserve --resource_ids strings Reserouce IDs --seq uint Sequence number of the transaction --wallet string Wallet type (soft|nano) (default "soft") Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") SEE ALSO: * [thetacli tx](thetacli_tx.md) - Manage transactions ``` -------------------------------- ### Building HIDAPI on Windows (Visual Studio) Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Instructions for building HIDAPI and its Test GUI on Windows using Visual Studio by compiling the provided .sln files located in the respective directories. ```bash # Build HIDAPI DLL: # Open and build windows/.sln # Build Test GUI: # Open and build testgui/.sln ``` -------------------------------- ### Windows Prerequisites (Fox-Toolkit) Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Details on obtaining pre-built Fox-toolkit binaries for Windows via the hidapi-externals.zip package, necessary for building the test GUI. The package should be extracted alongside the hidapi source directory. ```bash # Extract hidapi-externals.zip to the parent directory of hidapi ``` -------------------------------- ### Building HIDAPI on Windows (MinGW/Cygwin) Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Guidance for building HIDAPI on Windows using MinGW or Cygwin. It directs users to follow the 'Unix Platforms' Autotools instructions and notes the requirement for hidapi-externals.zip for the Test GUI. ```bash # Use instructions from 'Building HIDAPI into a shared library on Unix Platforms' # For Test GUI with MinGW/Cygwin, ensure hidapi-externals.zip is set up. ``` -------------------------------- ### Building HIDAPI Manually (Unix Platforms) Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Instructions for building HIDAPI using manual Makefiles, primarily for embedding directly into other projects. Demonstrates building for Linux and the test GUI. ```makefile # Example for Linux: cd linux/ make -f Makefile-manual # Example for Test GUI: cd testgui/ make -f Makefile-manual ``` -------------------------------- ### Build HIDAPI on Windows using DDK Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Instructions for building HIDAPI on Windows using the Windows Driver Kit (WDK). This process involves setting up the build environment and executing the build command. ```shell 1. Install the Windows Driver Kit (WDK) from Microsoft. 2. From the Start menu, in the Windows Driver Kits folder, select Build Environments, then your operating system, then the x86 Free Build Environment (or one that is appropriate for your system). 3. From the console, change directory to the windows/ddk_build/ directory, which is part of the HIDAPI distribution. 4. Type build. 5. You can find the output files (DLL and LIB) in a subdirectory created by the build system which is appropriate for your environment. On Windows XP, this directory is objfre_wxp_x86/i386. ``` -------------------------------- ### Theta CLI Options Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/ledger/theta.md Lists the available command-line options for the Theta CLI tool. These options control configuration, help display, and snapshot paths. ```APIDOC Theta CLI Commands: theta Synopsis: Theta Options: --config string config path (default is /Users//.theta) (default "/Users//.theta") -h, --help help for theta --snapshot string snapshot path SEE ALSO: * [theta init](theta_init.md) - Initialize Theta node configuration. * [theta start](theta_start.md) - Start Theta node. * [theta version](theta_version.md) - Print version of current Theta binary. Note: Auto generated by spf13/cobra on 24-Apr-2019 ``` -------------------------------- ### Logging Metrics to Syslog Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Sets up a goroutine to periodically emit all metrics from the default registry to syslog in a slightly more parseable format. ```go import ( "log/syslog" "github.com/rcrowley/go-metrics" ) w, _ := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics") go metrics.Syslog(metrics.DefaultRegistry, 60e9, w) ``` -------------------------------- ### thetacli backup chain Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_backup_chain.md Documentation for the thetacli backup chain command, detailing its usage, parameters, and inherited options. ```APIDOC Command: thetacli backup chain Description: Backup chain. Synopsis: thetacli backup chain [flags] Examples: thetacli backup chain Options: --end uint Ending block height -h, --help help for chain --start uint Starting block height Inherited Options: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") See Also: thetacli backup - Manage backups Auto generated by spf13/cobra on 24-Apr-2019 ``` -------------------------------- ### Emitting Metrics to Librato Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Configures a goroutine to periodically send all metrics to Librato. Requires the go-metrics-librato client library. Specifies account, token, source, percentiles, and time unit. ```go import ( "time" "github.com/mihasya/go-metrics-librato" "github.com/rcrowley/go-metrics" ) go librato.Librato(metrics.DefaultRegistry, 10e9, // interval "example@example.com", // account owner email address "token", // Librato API token "hostname", // source []float64{0.95}, // percentiles to send time.Millisecond, // time unit ) ``` -------------------------------- ### Theta Init Command: Initialize Node Configuration Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/ledger/theta_init.md Initializes the Theta node configuration. This command sets up the necessary configuration files and directories for running a Theta node. It accepts various flags to customize the initialization process. ```APIDOC theta init [flags] Synopsis: Initialize Theta node configuration. Options: -h, --help help for init Description: help for init Inherited Options: --config string config path (default is /Users//.theta) Description: The path to the configuration file. Defaults to /Users//.theta. Default: "/Users//.theta" --snapshot string snapshot path Description: The path to the snapshot file. ``` -------------------------------- ### thetacli daemon Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_daemon.md Documentation for the 'thetacli daemon' command, used to run the ThetaCli Daemon. It covers the command's purpose, synopsis, and available options. ```APIDOC thetacli daemon Synopsis: Run the ThetaCli Daemon Options: -h, --help help for daemon Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") SEE ALSO: * [thetacli](thetacli.md) - Theta wallet * [thetacli daemon start](thetacli_daemon_start.md) - Run the thatacli daemon Auto generated by spf13/cobra on 24-Apr-2019 ``` -------------------------------- ### Emitting Metrics to StatHat Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Sets up a goroutine to periodically send all metrics to StatHat. Requires the go-metrics/stathat client and the stathat/go client library. ```go import ( "github.com/rcrowley/go-metrics/stathat" "github.com/rcrowley/go-metrics" ) go stathat.Stathat(metrics.DefaultRegistry, 10e9, "example@example.com") ``` -------------------------------- ### thetacli key list Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_key_list.md Lists all keys managed by the thetacli command-line tool. It provides options for help and configuration path. ```APIDOC thetacli key list Synopsis: List all keys. Usage: thetacli key list [flags] Options: -h, --help help for list Inherited Options: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") See Also: thetacli key - Manage keys Auto generated by spf13/cobra on 24-Apr-2019 ``` -------------------------------- ### HIDAPI Core Functions Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Provides essential functions for interacting with HID devices. These include initializing and cleaning up the library, opening and closing device handles, and retrieving device information strings. ```APIDOC HIDAPI Core Functions: hid_init() Initializes the HIDAPI library. Must be called before any other HIDAPI functions. Returns: 0 on success, -1 on error. hid_exit() Finalizes the HIDAPI library. Must be called before the application exits. Returns: 0 on success, -1 on error. hid_open(vid, pid, serial_number) Opens a HID device by Vendor ID (VID) and Product ID (PID). An optional serial number can be provided to open a specific device. Parameters: vid: The Vendor ID of the device (unsigned short). pid: The Product ID of the device (unsigned short). serial_number: A wide character string representing the serial number, or NULL to open the first matching device. Returns: A pointer to a hid_device structure representing the opened device, or NULL if an error occurred. hid_open_path(path) Opens a HID device by its path. Parameters: path: The path to the device. Returns: A pointer to a hid_device structure representing the opened device, or NULL if an error occurred. hid_close(device) Closes a HID device. Parameters: device: A pointer to the hid_device structure to close. hid_write(device, data, length) Writes a HID packet to the device. Parameters: device: A pointer to the hid_device structure. data: A pointer to the data buffer to write. length: The number of bytes to write. Returns: The number of bytes written, or -1 on error. hid_read(device, data, length) Reads a HID packet from the device. This is a blocking call. Parameters: device: A pointer to the hid_device structure. data: A pointer to the buffer to store the read data. length: The maximum number of bytes to read. Returns: The number of bytes read, or -1 on error. hid_read_timeout(device, data, length, milliseconds) Reads a HID packet from the device with a timeout. Parameters: device: A pointer to the hid_device structure. data: A pointer to the buffer to store the read data. length: The maximum number of bytes to read. milliseconds: The timeout in milliseconds. 0 for non-blocking, -1 for blocking. Returns: The number of bytes read, or -1 on error or timeout. hid_set_nonblocking(device, nonblocking) Sets the read operation to be blocking or non-blocking. Parameters: device: A pointer to the hid_device structure. nonblocking: 1 for non-blocking, 0 for blocking. Returns: 0 on success, -1 on error. hid_get_manufacturer_string(device, buf, len) Retrieves the manufacturer string from the device. Parameters: device: A pointer to the hid_device structure. buf: A buffer to store the string (wchar_t*). len: The size of the buffer. Returns: The number of characters written to the buffer, or -1 on error. hid_get_product_string(device, buf, len) Retrieves the product string from the device. Parameters: device: A pointer to the hid_device structure. buf: A buffer to store the string (wchar_t*). len: The size of the buffer. Returns: The number of characters written to the buffer, or -1 on error. hid_get_serial_number_string(device, buf, len) Retrieves the serial number string from the device. Parameters: device: A pointer to the hid_device structure. buf: A buffer to store the string (wchar_t*). len: The size of the buffer. Returns: The number of characters written to the buffer, or -1 on error. hid_get_indexed_string(device, index, buf, len) Retrieves an indexed string from the device. Parameters: device: A pointer to the hid_device structure. index: The index of the string to retrieve. buf: A buffer to store the string (wchar_t*). len: The size of the buffer. Returns: The number of characters written to the buffer, or -1 on error. hid_error(device) Returns a string describing the last error that occurred. Parameters: device: A pointer to the hid_device structure. Returns: A C-string describing the error, or NULL if no error. hid_enumerate() Enumerates all HID devices connected to the system. Returns: A linked list of hid_device_info structures, or NULL if no devices are found or an error occurs. The list must be freed using hid_free_enumeration(). hid_free_enumeration(devs) Frees the list of HID devices obtained from hid_enumerate(). Parameters: devs: The linked list of hid_device_info structures. ``` -------------------------------- ### Exposing Metrics via expvar Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Integrates go-metrics with the standard Go expvar package, exposing all registered metrics and expvars under the `/debug/metrics` endpoint as a JSON representation. ```go import ( "github.com/rcrowley/go-metrics/exp" "github.com/rcrowley/go-metrics" ) exp.Exp(metrics.DefaultRegistry) ``` -------------------------------- ### Emitting Metrics to InfluxDB Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Sets up a goroutine to periodically send all metrics to an InfluxDB instance. Note: Client libraries for InfluxDB are being deprecated; refer to library issues for details. ```go import ( "github.com/vrischmann/go-metrics-influxdb" "github.com/rcrowley/go-metrics" ) go influxdb.InfluxDB(metrics.DefaultRegistry, 10e9, "127.0.0.1:8086", "database-name", "username", "password" ) ``` -------------------------------- ### Theta CLI Backup Command Options Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_backup.md Details the available options for the Theta CLI backup command, including help flags and configuration path settings. This section outlines the command's structure and inherited configurations. ```CLI thetacli backup Manage backups Synopsis: Manage backups. Options: -h, --help help for backup Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") SEE ALSO: * [thetacli](thetacli.md) - Theta wallet * [thetacli backup chain](thetacli_backup_chain.md) - backup chain * [thetacli backup snapshot](thetacli_backup_snapshot.md) - backup snapshot ###### Auto generated by spf13/cobra on 24-Apr-2019 ``` -------------------------------- ### Cross-Compile HIDAPI for Embedded Linux Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/wallet/coldwallet/hid/hidapi/README.txt Steps for cross-compiling HIDAPI for embedded Linux targets. This involves setting up environment variables, building prerequisites like libusb and libudev, and then configuring and building HIDAPI. ```shell # Set environment variables for cross-compilation export STAGING=$HOME/out export HOST=arm-linux # Build Libusb # From the libusb source directory, run: ./configure --host=$HOST --prefix=$STAGING make make install # Build libudev # From the libudev source directory, run: ./configure --disable-gudev --disable-introspection --disable-hwdb \ --host=$HOST --prefix=$STAGING make make install # Building HIDAPI # Configure HIDAPI for cross-compilation: PKG_CONFIG_DIR= \ PKG_CONFIG_LIBDIR=$STAGING/lib/pkgconfig:$STAGING/share/pkgconfig \ PKG_CONFIG_SYSROOT_DIR=$STAGING \ ./configure --host=$HOST --prefix=$STAGING ``` -------------------------------- ### Emitting Metrics to Graphite Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Configures a goroutine to periodically send all metrics from the default registry to a Graphite endpoint. Requires the go-metrics-graphite client library. ```go import ( "net" "github.com/cyberdelia/go-metrics-graphite" "github.com/rcrowley/go-metrics" ) addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003") go graphite.Graphite(metrics.DefaultRegistry, 10e9, "metrics", addr) ``` -------------------------------- ### Logging Metrics to Standard Error Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Configures a goroutine to periodically log all metrics from the default registry to standard error in a human-readable format. ```go import ( "log" "os" "time" "github.com/rcrowley/go-metrics" ) go metrics.Log(metrics.DefaultRegistry, 5*time.Second, log.New(os.Stderr, "metrics: ", log.Lmicroseconds)) ``` -------------------------------- ### Query Account Status with thetacli Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_query_account.md Retrieves the status of an account using the thetacli command-line interface. This command requires the account's address and can optionally include a preview flag for balance screening. Inherited options, such as the configuration path, are also supported. ```shell thetacli query account [flags] ``` ```shell thetacli query account --address=0x2E833968E5bB786Ae419c4d13189fB081Cc43bab ``` ```shell Options: --address string Address of the account -h, --help help for account --preview Preview account balance from the screened view Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") ``` -------------------------------- ### thetacli Global Options Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli.md Global options available for the thetacli command-line interface. These options control configuration paths and help display. ```APIDOC Options: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") -h, --help help for thetacli ``` -------------------------------- ### thetacli query Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli_query.md Documentation for the 'thetacli query' command, which allows users to query entities stored in the blockchain. It details the command's synopsis, available options, and inherited flags. ```APIDOC thetacli query Query entities stored in blockchain Synopsis: Query entities stored in blockchain Options: -h, --help help for query Options inherited from parent commands: --config string config path (default is /Users//.thetacli) (default "/Users//.thetacli") Related Commands: thetacli query account thetacli query block thetacli query split_rule thetacli query status thetacli query tx thetacli query vcp thetacli query version ``` -------------------------------- ### thetacli Related Commands Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/wallet/thetacli.md A list of related commands and their brief descriptions for the thetacli tool. These commands cover various functionalities like key management, transaction handling, and smart contract interaction. ```APIDOC SEE ALSO: * [thetacli backup](thetacli_backup.md) - Manage backups * [thetacli call](thetacli_call.md) - Call smart contract APIs * [thetacli daemon](thetacli_daemon.md) - Run the ThetaCli Daemon * [thetacli key](thetacli_key.md) - Manage keys * [thetacli query](thetacli_query.md) - Query entities stored in blockchain * [thetacli tx](thetacli_tx.md) - Manage transactions ``` -------------------------------- ### Theta CLI Version Command Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/docs/commands/ledger/theta_version.md Prints the version of the current Theta binary. Includes details on available flags and configuration options. ```APIDOC theta version Synopsis: Prints version of current Theta binary. Usage: theta version [flags] Options: -h, --help help for version Inherited Options: --config string config path (default is /Users//.theta) (default "/Users//.theta") --snapshot string snapshot path Description: The 'theta version' command displays the version information of the Theta binary. It provides a simple way to check the installed Theta client version. Parameters: -h, --help: Displays help information for the version command. --config string: Specifies the path to the Theta configuration file. Defaults to '/Users//.theta'. --snapshot string: Specifies the path for snapshot operations. Returns: Prints the Theta binary version to standard output. See Also: theta: The main Theta command-line interface. ``` -------------------------------- ### Thread-Safe Metric Registration Source: https://github.com/thetatoken/theta-protocol-ledger/blob/master/common/metrics/README.md Shows how to use GetOrRegister for thread-safe registration of metrics, ensuring that a metric is only registered once even if multiple goroutines attempt to register it simultaneously. ```go t := metrics.GetOrRegisterTimer("account.create.latency", nil) t.Time(func() { /* operation */ }) t.Update(47) ```