### Start Nimiq Client Source: https://www.nimiq.com/developers/build/set-up-your-own-node/prover-node-guide This command initiates the Nimiq client after it has been installed. It's the essential first step to run the client and proceed with further configuration and operation. ```bash cargo run --release --bin nimiq-client ``` -------------------------------- ### Run Nimiq Client from Source Source: https://www.nimiq.com/developers/build/integrator-guide This command executes the compiled `nimiq-client` binary directly from the source code directory using Cargo. The `--release` flag ensures it runs the optimized build. ```bash cargo run --release --bin nimiq-client ``` -------------------------------- ### Download Nimiq Proving Keys via Magnet Link Source: https://www.nimiq.com/developers/build/set-up-your-own-node/prover-node-guide This magnet link provides an alternative method to download the substantial Nimiq ZKP proving keys using a BitTorrent client. These keys are crucial for activating the ZK Prover functionality on the node. ```bash magnet:?xt=urn:btih:2cc3ca7888b75f1c38f2c4013f6eb3631946e2e9&dn=nimiq-zkp-keys&tr=udp%3A%2F%2Ftorrent.nimiq.network%3A6969 ``` -------------------------------- ### Install Nimiq Client Build Dependencies (Ubuntu) Source: https://www.nimiq.com/developers/build/integrator-guide This command updates package lists and installs essential build packages required for compiling the Nimiq client from source on an Ubuntu system. These include clang, cmake, libssl-dev, and pkg-config. ```bash apt update && apt install clang cmake libssl-dev pkg-config ``` -------------------------------- ### Query Nimiq RPC Client Utility Source: https://www.nimiq.com/developers/build/integrator-guide These commands show how to use the `nimiq-rpc` utility, a command-line interface for interacting with the Nimiq JSON-RPC API. The first command displays help, and the second demonstrates how to connect to an RPC endpoint with a URL, username, and password. ```bash cargo run --release --bin nimiq-rpc -- --help cargo run --release --bin nimiq-rpc -- -u URL -U username -P password ``` -------------------------------- ### Generate Nimiq Address and Key Pair Utility Source: https://www.nimiq.com/developers/build/integrator-guide These commands demonstrate how to use the `nimiq-address` utility binary. The first command shows the help message, and the second runs the utility to generate a new Nimiq address, public key, and private key. ```bash cargo run --release --bin nimiq-address -- --help cargo run --release --bin nimiq-address ``` -------------------------------- ### Compile Nimiq Client from Source Source: https://www.nimiq.com/developers/build/integrator-guide This command compiles the `nimiq-client` binary from the source code repository using Cargo, Rust's package manager and build system. The `--release` flag ensures an optimized, production-ready build. ```bash cargo build --release --bin nimiq-client ``` -------------------------------- ### Restart Nimiq Client to Apply Changes Source: https://www.nimiq.com/developers/build/set-up-your-own-node/prover-node-guide This command is used to restart the Nimiq client after any configuration modifications, such as enabling the ZK Prover or updating the proving keys path. A client restart is necessary for the newly applied settings to take effect. ```bash cargo run --release --bin nimiq-client ``` -------------------------------- ### NPM Installation of Nimiq Utils Source: https://www.nimiq.com/developers/build/nimiq-utils Instructions for installing the Nimiq Utils library using npm. ```bash npm install @nimiq/utils ``` -------------------------------- ### Install Nimiq Core Light Client Source: https://www.nimiq.com/developers/build/web-client/reference Instructions for installing the Nimiq Albatross Light Client package using npm, yarn, or pnpm. ```sh npm install @nimiq/core yarn add @nimiq/core pnpm install @nimiq/core ``` -------------------------------- ### Nimiq Client Exposed Ports Overview Source: https://www.nimiq.com/developers/build/integrator-guide This section documents the network ports exposed by the Nimiq client, detailing their purpose for incoming connections, RPC communication, and metrics. ```APIDOC Port: 8443 Description: Incoming network connections port Port: 8648 Description: RPC port Port: 9100 Description: Metrics port ``` -------------------------------- ### Enable ZK Prover in Nimiq Configuration Source: https://www.nimiq.com/developers/build/set-up-your-own-node/prover-node-guide This TOML configuration block enables the ZK Prover functionality in the Nimiq client. It shows how to uncomment the `[zk-prover]` section and specify the `prover_keys_path` to the directory where the downloaded proving keys are located, typically `~/.zkp_mainnet`. ```toml ############################################################################## # ZK Prover configuration # # If the section header is uncommented, the prover is enabled. ############################################################################## [zk-prover] # The path for the proving keys folder. # Default: ".zkp" prover_keys_path = "~/.zkp_mainnet" ``` -------------------------------- ### Nimiq PoS Blockchain Network Parameters Source: https://www.nimiq.com/developers/build/integrator-guide This section outlines key network parameters for the Nimiq Proof-of-Stake blockchain, including block timing, transaction capacity, and epoch structure. ```APIDOC Parameter: Block frequency target Details: 1 block per second Parameter: Maximum transactions per second Details: ~700 transactions Parameter: Blocks per batch Details: 60 blocks Parameter: Batches per epoch Details: 720 batches Parameter: Blocks per epoch Details: 43’200 blocks Parameter: Epoch duration Details: ~12 hours Parameter: Transaction validity window Details: 7’200 blocks (~2 hours) Parameter: Transaction finality Details: After the next macro block (end of every batch) ``` -------------------------------- ### Nimiq Web Client: Listen for Blockchain Head Changes (JavaScript) Source: https://www.nimiq.com/developers/build/web-client/getting-started This JavaScript snippet demonstrates how to subscribe to blockchain head changes using the Nimiq Web Client. It utilizes the `addHeadChangedListener` method to register a callback function that will be invoked whenever a new block head is detected, logging the new head's details to the console. This is a fundamental way to monitor the blockchain's progress and react to new blocks. ```js client.addHeadChangedListener((head) => { console.log('New head:', head) }) ``` -------------------------------- ### Nimiq PoS Node JSON-RPC Methods Overview Source: https://www.nimiq.com/developers/build/integrator-guide Overview of essential JSON-RPC methods for interacting with the Nimiq Proof-of-Stake (PoS) blockchain. These methods allow integrators to retrieve transaction details, block information, check consensus status, and create or broadcast transactions. ```APIDOC JSON-RPC Interface: The JSON-RPC interface provides methods for generating addresses, creating/sending transactions, retrieving balances and much more. The full specification is available at: https://www.nimiq.com/developers/build/set-up-your-own-node/rpc-docs/ Key JSON-RPC Methods: - getTransactionByHash(transactionHash: string): Description: Retrieve transaction details using a transaction hash. - getTransactionHashesByAddress(address: string): Description: Fetch transaction hashes associated with a given address. - getBlockNumber(): Description: Returns the current head block of the node. - getBlockByNumber(blockNumber: number): Description: Returns the block at the specified height. - getRawTransactionInfo(serializedTransaction: string): Description: Get raw transaction details by decoding a serialized transaction. - isConsensusEstablished(): Description: Returns a boolean specifying if the node has established consensus with the network. - createBasicTransaction(params: object): Description: Create a signed transaction and returns a hex-encoded representation without broadcasting it. All `create*Transaction` RPC methods also have an equivalent `send*Transaction` version to create and broadcast the transaction in one go. - sendRawTransaction(serializedSignedTransaction: string): Description: Sends the given serialized and signed transaction to the network. ``` -------------------------------- ### Sign Nimiq Transaction Utility Source: https://www.nimiq.com/developers/build/integrator-guide These commands illustrate the usage of the `nimiq-signtx` utility for signing blockchain transactions. The first command displays available options, while the second provides a template for signing a transaction with required parameters like sender, recipient, value, fee, and network details. ```bash cargo run --release --bin nimiq-signtx -- --help cargo run --release --bin nimiq-signtx -- --secret-key --from --to --value --fee --validity-start-height --network ``` -------------------------------- ### Run Nimiq Client Docker Container (Non-History/Non-Mainnet) Source: https://www.nimiq.com/developers/build/integrator-guide This command runs the Nimiq client via Docker for configurations other than a mainnet history node. It mounts the local 'data' directory, maps necessary ports, and names the container 'nimiq-rpc'. ```bash docker run -v $(pwd)/data:/home/nimiq/.nimiq -p 8443:8443 -p 8648:8648 -p 9100:9100 --name nimiq-rpc --rm ghcr.io/nimiq/core-rs-albatross:latest ``` -------------------------------- ### API: Start WASM Bindgen Module Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Initializes the `wasm-bindgen` module. This function is typically called once to set up the WebAssembly environment and prepare it for execution. ```APIDOC __wbindgen_start: readonly __wbindgen_start: () => void Defined in: @nimiq/core/types/wasm/web.d.ts:2602 Parameters: Returns: void ``` -------------------------------- ### Initialize Nimiq Client with CommonJS Source: https://www.nimiq.com/developers/build/web-client/integrations/CommonJS This snippet demonstrates how to import the Nimiq Web Client using `require` for CommonJS environments and initialize a new Nimiq client instance. It sets up a basic configuration and creates the client asynchronously. ```javascript const Nimiq = require('@nimiq/core') async function main() { const config = new Nimiq.ClientConfiguration() const client = await Nimiq.Client.create(config.build()) } main() ``` -------------------------------- ### Configure Nimiq Node Sync Mode Source: https://www.nimiq.com/developers/build/set-up-your-own-node/prover-node-guide This TOML snippet demonstrates how to set the Nimiq node's synchronization mode to 'full' within the `client.toml` configuration file. Operating in 'full' sync mode is a mandatory requirement for a node to be eligible as a prover, ensuring it possesses the complete blockchain data. ```toml [consensus] sync_mode = "full" ``` -------------------------------- ### Instantiate Nimiq Client in NodeJS Source: https://www.nimiq.com/developers/build/web-client/reference Provides examples for importing the Nimiq client in NodeJS using both CommonJS and ESM, demonstrating how to configure and launch the client within an async function. ```js // Import as CommonJS module const Nimiq = require("@nimiq/core"); // Or import as ESM module import * as Nimiq from "@nimiq/core"; // In ESM modules you can use await at the top-level and do not need an async wrapper function. async function main() { // Create a configuration builder: const config = new Nimiq.ClientConfiguration(); // Change the config as shown above, if necessary // ... // Instantiate and launch the client: const client = await Nimiq.Client.create(config.build()); } main(); ``` -------------------------------- ### Run Nimiq Client Docker Container (Mainnet History Node) Source: https://www.nimiq.com/developers/build/integrator-guide This command runs the Nimiq client as a history node on the mainnet using Docker. It mounts the local 'data' directory, maps necessary ports, and sets an environment variable to override the mainnet configuration with a specified genesis file. ```bash docker run -v $(pwd)/data:/home/nimiq/.nimiq -p 8443:8443 -p 8648:8648 -p 9100:9100 -e NIMIQ_OVERRIDE_MAINNET_CONFIG=/home/nimiq/.nimiq/nimiq-genesis-main-albatross.toml --name nimiq-rpc --rm ghcr.io/nimiq/core-rs-albatross:latest ``` -------------------------------- ### Install Nimiq CSS Typography Package Source: https://www.nimiq.com/developers/build/ui/design/typography Commands to install the `nimiq-css` package using different Node.js package managers: npm, pnpm, and yarn. ```sh npm install nimiq-css ``` ```sh pnpm add nimiq-css ``` ```sh yarn add nimiq-css ``` -------------------------------- ### Execute Debug Protocol via npm Source: https://www.nimiq.com/developers/build/ui/design/typography/demo This bash command sequence illustrates how to initiate a debugging process. It first echoes a message indicating the start of the debug protocol, then executes the `npm run debug` command, a common practice in Node.js development environments for running predefined debug scripts. ```bash echo "Running debug protocol..." npm run debug ``` -------------------------------- ### Install ARPL RPC Client Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator Instructions to install 'arpl', a Nimiq-specific RPC client, using the npm package manager. This tool is used for sending JSON-RPC commands to the Nimiq node. ```bash npm install -g @sisou/albatross-remote ``` -------------------------------- ### Start ARPL REPL Session Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator Initiates an interactive ARPL (Nimiq RPC client) session. This allows developers to directly execute commands against a Nimiq node for various administrative and query operations. ```ARPL arpl repl ``` -------------------------------- ### Check Nimiq Node Status with ARPL Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator Bash commands demonstrating how to use the `arpl` utility to connect to the Nimiq node's JSON-RPC server and open an interactive session. Examples include specifying the WebSocket URL with host and port, and using separate host/port flags, with defaults for `localhost:8648`. ```bash arpl repl -u ws://:/ws # -u is short for --url # With default settings: arpl repl -u ws://localhost:8648/ws # You can also use other ways of specifying the connection parameters: arpl repl -h localhost -p 8648 # -h is short for --host, -p is short for --port # The defaults of the node configuration are also the defaults for ``` -------------------------------- ### Query Nimiq Validator State Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator This section provides commands to query the current state and details of a registered Nimiq validator. Examples are given for both ARPL and cURL JSON-RPC, showing how to retrieve public keys, reward address, staking balance, and operational status. ```ARPL validator:get ``` ```bash curl 'http://localhost:8648' -H 'Content-Type: application/json' \ --data-raw '{"method": "getValidatorByAddress", "params": [""], "jsonrpc": "2.0", "id": 1}' ``` -------------------------------- ### Create ES256PublicKey from Webauthn Credential Source: https://www.nimiq.com/developers/build/web-client/reference/classes/ES256PublicKey This JavaScript example demonstrates how to create a Webauthn credential using the ES256 algorithm and subsequently instantiate an ES256PublicKey object from the public key data obtained from the credential response. ```javascript // Create/register a credential with the Webauthn API: const cred = await navigator.credentials.create({ publicKey: { pubKeyCredParams: [{ type: "public-key", alg: -7 // ES256 = ECDSA over P-256 with SHA-256 }], // ... } }); // Then create an instance of ES256PublicKey from the credential response: const publicKey = new Nimiq.ES256PublicKey(new Uint8Array(cred.response.getPublicKey())); ``` -------------------------------- ### Manage Cookies with Nimiq Utils Source: https://www.nimiq.com/developers/build/nimiq-utils Provides examples for using the cookie utility functions (getCookie, setCookie, unsetCookie) to manage browser cookies, including setting properties like path, maxAge, and secure flags. ```typescript import { getCookie, setCookie, unsetCookie } from '@nimiq/utils/cookie' // Example: Get a cookie const cookieValue = getCookie('session') console.log(cookieValue) // Output: The value of the 'session' cookie, or null if not found // Example: Set a cookie const cookieString = setCookie('session', 'abc123', { path: '/', maxAge: 3600, secure: true }) console.log(cookieString) // Output: 'session=abc123;path=/;max-age=3600;secure' // Example: Unset a cookie unsetCookie('session') console.log(getCookie('session')) // Output: null ``` -------------------------------- ### Get Transaction Validity Start Height Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the validity start height of a Nimiq transaction. This is a core WASM function. ```APIDOC transaction_validityStartHeight: (a: number) => number a: number Returns: number Defined in: @nimiq/core/types/wasm/web.d.ts:2316 ``` -------------------------------- ### Add Stake to a Nimiq Validator Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator This snippet illustrates how to initiate a staking transaction to delegate NIM to a validator. It provides examples for the ARPL command-line tool and a cURL JSON-RPC call, detailing the required parameters such as staker address, validator address, and the amount to stake. ```ARPL stake:start ``` ```bash curl 'http://localhost:8648' -H 'Content-Type: application/json' \ --data-raw '{"method": "sendNewStakerTransaction", "params": ["", "", "", , 0, "+0"], "jsonrpc": "2.0", "id": 1}' ``` -------------------------------- ### clientconfiguration_build API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the clientconfiguration_build method, detailing its signature, parameters, and return type. ```APIDOC readonly clientconfiguration_build: (a: number) => any a: number ``` -------------------------------- ### clientconfiguration_new API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the clientconfiguration_new method, detailing its signature, parameters, and return type. ```APIDOC readonly clientconfiguration_new: () => number ``` -------------------------------- ### Initialize Nimiq Client with ES Modules Source: https://www.nimiq.com/developers/build/web-client/reference Shows how to import the Nimiq client using ES Modules, initialize the WASM file, and then configure and create a client instance within the promise chain. ```js // Import the loader and package from the /web path: import init, * as Nimiq from '@nimiq/core/web'; // Load and initialize the WASM file init().then(() => { // Create a configuration builder: const config = new Nimiq.ClientConfiguration(); // Change the config as shown above, if necessary // ... // Instantiate and launch the client: const client = await Nimiq.Client.create(config.build()); }); ``` -------------------------------- ### Configure and Instantiate Nimiq Client with Bundlers Source: https://www.nimiq.com/developers/build/web-client/reference Demonstrates how to import, configure, and create a Nimiq client instance when using bundlers like Webpack or Vite, including network, seed node, and log level configuration. ```js // With Webpack: import the package asynchronously: const Nimiq = await import('@nimiq/core'); // With Vite, import at the top of your file: import * as Nimiq from '@nimiq/core'; // Create a configuration builder: const config = new Nimiq.ClientConfiguration(); // Change the config, if necessary: // -------------------------------- // Specify the network to use: // Optional, default is 'mainalbatross' config.network('testalbatross'); // Specify the seed nodes to initially connect to: // Optional, default is the mainnet seed list config.seedNodes(['/dns4/seed1.pos.nimiq-testnet.com/tcp/8443/wss']); // Change the lowest log level that is output to the console: // Optional, default is 'info' config.logLevel('debug'); // Instantiate and launch the client: const client = await Nimiq.Client.create(config.build()); ``` -------------------------------- ### Initialize Nimiq WASM Client Source: https://www.nimiq.com/developers/build/web-client/reference/classes/Client Demonstrates how to import and initialize the Nimiq WASM client, then instantiate a Client object for further interaction with the Nimiq blockchain. ```js import init, * as Nimiq from "./pkg/nimiq_web_client.js"; init().then(async () => { const config = new Nimiq.ClientConfiguration(); const client = await config.instantiateClient(); // ... }); ``` -------------------------------- ### Nimiq Core: initSync() Function API Reference Source: https://www.nimiq.com/developers/build/web-client/reference/functions/initSync Detailed API documentation for the `initSync` function from the `@nimiq/core` library. This function instantiates a WebAssembly module, accepting either bytes or a precompiled `WebAssembly.Module`. ```APIDOC Function: initSync Signature: initSync(module: SyncInitInput | { module: SyncInitInput }): InitOutput Description: Instantiates the given `module`, which can either be bytes or a precompiled `WebAssembly.Module`. Defined In: @nimiq/core/types/wasm/web.d.ts:2614 Parameters: module: Type: { module: SyncInitInput; } | SyncInitInput Description: The module to instantiate. Passing `SyncInitInput` directly is deprecated. Returns: Type: InitOutput ``` -------------------------------- ### clientconfiguration_network API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the clientconfiguration_network method, detailing its signature, parameters, and return type. ```APIDOC readonly clientconfiguration_network: (a: number, b: number, c: number) => [number, number] a: number b: number c: number ``` -------------------------------- ### Get Transaction Value Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the value of a Nimiq transaction. This is a core WASM function. ```APIDOC transaction_value: (a: number) => bigint a: number Returns: bigint Defined in: @nimiq/core/types/wasm/web.d.ts:2313 ``` -------------------------------- ### clientconfiguration_logLevel API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the clientconfiguration_logLevel method, detailing its signature, parameters, and return type. ```APIDOC readonly clientconfiguration_logLevel: (a: number, b: number, c: number) => void a: number b: number c: number ``` -------------------------------- ### Get Transaction Sender Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the sender of a Nimiq transaction. This is a core WASM function. ```APIDOC transaction_sender: (a: number) => number a: number Returns: number Defined in: @nimiq/core/types/wasm/web.d.ts:2309 ``` -------------------------------- ### API: client_create Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Creates a new instance of the Nimiq client. It takes an 'any' type as configuration or initial parameters and returns an 'any' type representing the created client instance. ```APIDOC client_create: Signature: (a) => any Parameters: a: any Returns: any ``` -------------------------------- ### Get Network Identifier: getNetworkId() Source: https://www.nimiq.com/developers/build/web-client/reference/classes/Client Returns the unique identifier of the network to which the client is currently connected. ```APIDOC getNetworkId(): Promise Returns: Promise ``` -------------------------------- ### Get Transaction Sender Type Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the sender type of a Nimiq transaction. This is a core WASM function. ```APIDOC transaction_senderType: (a: number) => number a: number Returns: number Defined in: @nimiq/core/types/wasm/web.d.ts:2310 ``` -------------------------------- ### Get Transaction Sender Data Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the sender data of a Nimiq transaction. This is a core WASM function. ```APIDOC transaction_senderData: (a: number) => [number, number] a: number Returns: [number, number] Defined in: @nimiq/core/types/wasm/web.d.ts:2321 ``` -------------------------------- ### Get Transaction Recipient Type Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the recipient type of a Nimiq transaction. This is a core WASM function. ```APIDOC transaction_recipientType: (a: number) => number a: number Returns: number Defined in: @nimiq/core/types/wasm/web.d.ts:2312 ``` -------------------------------- ### Get Nimiq Transaction Serialized Size Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Calculates the serialized size of a Nimiq transaction. This is a core WASM function. ```APIDOC transaction_serializedSize: (a: number) => number a: number Returns: number Defined in: @nimiq/core/types/wasm/web.d.ts:2324 ``` -------------------------------- ### Initialize Nimiq Web Client with WebAssembly Import Source: https://www.nimiq.com/developers/build/web-client/integrations/webpack This code demonstrates the process of importing the Nimiq Web Client using `await import()`, which is necessary for loading its WebAssembly module. It then shows how to configure and create a Nimiq client instance and wait for consensus to be established on the network. ```javascript const Nimiq = await import('@nimiq/core') // You need to use await import() to load the WebAssembly module const config = new Nimiq.ClientConfiguration() const client = await Nimiq.Client.create(config.build()) await client.waitForConsensusEstablished() ``` -------------------------------- ### Get Current Head Block Hash: getHeadHash() Source: https://www.nimiq.com/developers/build/web-client/reference/classes/Client Returns the cryptographic hash of the current blockchain head block. ```APIDOC getHeadHash(): Promise Returns: Promise ``` -------------------------------- ### Uint8Array.fill() Method Source: https://www.nimiq.com/developers/build/web-client/reference/classes/SerialBuffer Changes all array elements from `start` to `end` index to a static `value` and returns the modified array. ```APIDOC fill(value: number, start?: number, end?: number): this value: number - value to fill array section with start?: number - index to start filling the array at. If start is negative, it is treated as length+start where length is the length of the array. end?: number - index to stop filling the array at. If end is negative, it is treated as length+end. Returns: this Inherited from: Uint8Array.fill ``` -------------------------------- ### StringUtils Class API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/classes/StringUtils This section provides the full API documentation for the StringUtils class, outlining its constructor and static methods. It includes details on method signatures, parameters, return types, and their definitions within the @nimiq/core library. ```APIDOC Class: StringUtils Defined in: @nimiq/core/lib/index.d.ts:327 Constructors: Constructor(): StringUtils Methods: static isHex(str: string): boolean Defined in: @nimiq/core/lib/index.d.ts:329 Parameters: str: string static isHexBytes(str: string, length?: number): boolean Defined in: @nimiq/core/lib/index.d.ts:330 Parameters: str: string length?: number static isWellFormed(str: string): boolean Defined in: @nimiq/core/lib/index.d.ts:328 Parameters: str: string ``` -------------------------------- ### lastIndexOf() method for Uint8Array Source: https://www.nimiq.com/developers/build/web-client/reference/classes/SerialBuffer Returns the index of the last occurrence of a value in an array, optionally starting the search from a specified index. ```APIDOC lastIndexOf(searchElement, fromIndex?): number searchElement: number The value to locate in the array. fromIndex?: number The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. Returns: number Inherited from: Uint8Array.lastIndexOf ``` -------------------------------- ### clientconfiguration_peerCountMax API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the clientconfiguration_peerCountMax method, detailing its signature, parameters, and return type. ```APIDOC readonly clientconfiguration_peerCountMax: (a: number, b: number) => void a: number b: number ``` -------------------------------- ### Nimiq Client Class API Reference Source: https://www.nimiq.com/developers/build/web-client/reference/classes/Client Comprehensive API documentation for the Nimiq Albatross Client class, detailing its constructor, methods, parameters, return types, and general usage. ```APIDOC Class: Client Description: Nimiq Albatross client that runs in browsers via WASM and is exposed to Javascript. Defined in: @nimiq/core/types/wasm/web.d.ts:789 Methods: addConsensusChangedListener(listener: (state) => any): Promise Description: Adds an event listener for consensus-change events, such as when consensus is established or lost. Parameters: listener: (state) => any addHeadChangedListener(listener: (hash, reason, reverted_blocks, adopted_blocks) => any): Promise Description: Adds an event listener for new blocks added to the blockchain. Parameters: listener: (hash, reason, reverted_blocks, adopted_blocks) => any addPeerChangedListener(listener: (peer_id, reason, peer_count, peer_info?) => any): Promise Description: Adds an event listener for peer-change events, such as when a new peer joins, or a peer leaves. Parameters: listener: (peer_id, reason, peer_count, peer_info?) => any addTransactionListener(listener: (transaction) => any, addresses: (string | Address | Uint8Array)[]): Promise Description: Adds an event listener for transactions to and from the provided addresses. The listener is called for transactions when they are *included* in the blockchain. Parameters: listener: (transaction) => any addresses: (string | Address | Uint8Array)[] connectNetwork(): Promise Description: This function is used to tell the network to (re)start connecting to peers. This is could be used to tell the network to restart connection operations after disconnect network is called. disconnectNetwork(): Promise Description: This function is used to tell the network to disconnect from every connected peer and stop trying to connect to other peers. Important: this function returns when the signal to disconnect was sent, before all peers actually disconnect. This means that in order to ensure the network is disconnected, wait for all peers to disappear after calling. free(): void Description: Releases resources held by the client instance. getAccount(address: string | Address | Uint8Array): Promise Description: Fetches the account for the provided address from the network. Throws if the address cannot be parsed and on network errors. Parameters: address: string | Address | Uint8Array getAccounts(addresses: (string | Address | Uint8Array)[]): Promise Description: Fetches the accounts for the provided addresses from the network. Throws if an address cannot be parsed and on network errors. Parameters: addresses: (string | Address | Uint8Array)[] getAddressBook(): Promise Description: Returns the current address books peers. Each peer will have one address and currently no guarantee for the usefulness of that address can be given. The resulting Array may be empty if there is no peers in the address book. getBlock(hash: string): Promise Description: Fetches a block by its hash. Throws if the client does not have the block. Fetching blocks from the network is not yet available. Parameters: hash: string ``` -------------------------------- ### Apply Nimiq Typography Styles to HTML Source: https://www.nimiq.com/developers/build/ui/design/typography Example HTML demonstrating how to apply the `nq-prose` class to an `
` element to enable sensible typography styles for its content. ```html

Your awesome content

...

``` -------------------------------- ### clientconfiguration_peerCountPerIpMax API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the clientconfiguration_peerCountPerIpMax method, detailing its signature, parameters, and return type. ```APIDOC readonly clientconfiguration_peerCountPerIpMax: (a: number, b: number) => void a: number b: number ``` -------------------------------- ### Configure Nimiq Node TLS Certificate Paths Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator TOML configuration for specifying the file paths to the private key and full certificates for TLS within the `[network.tls]` section of the Nimiq node's `client.toml`. Setting up TLS is strongly recommended for secure connections, especially for browser-based wallets. ```toml [network.tls] private_key = "/path/to/private_key_file.pem" certificates = "/path/to/full_certificates_file.pem" ``` -------------------------------- ### Get Keypair Public Key Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the public key from a keypair. This function takes one number parameter (a) and returns a single number. ```APIDOC keypair_publicKey: (a: number) => number a: number Returns: number ``` -------------------------------- ### Get Keypair Private Key Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the private key from a keypair. This function takes one number parameter (a) and returns a single number. ```APIDOC keypair_privateKey: (a: number) => number a: number Returns: number ``` -------------------------------- ### Enable Dark Mode for Nimiq Typography Source: https://www.nimiq.com/developers/build/ui/design/typography Example showing how to apply the `dark` class to a preceding parent element (e.g., ``) to automatically adjust typography styles for dark backgrounds. ```html

Your awesome content

...

``` -------------------------------- ### Get Partial Signature Class Name Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the class name for a partial signature. This function takes one number parameter (a) and returns an array of two numbers. ```APIDOC partialsignature___getClassname: (a: number) => [number, number] a: number Returns: [number, number] ``` -------------------------------- ### Nimiq PrivateKey Class API Reference Source: https://www.nimiq.com/developers/build/web-client/reference/classes/PrivateKey Detailed API documentation for the `PrivateKey` class from the `@nimiq/core` library, including its constructor, static and instance properties, and methods for key management. ```APIDOC Class: PrivateKey Description: The secret (private) part of an asymmetric key pair that is typically used to digitally sign or decrypt data. Defined in: @nimiq/core/types/wasm/web.d.ts:1685 Constructors: Constructor(bytes: Uint8Array): PrivateKey Description: Creates a new private key from a byte array. Throws when the byte array is not exactly 32 bytes long. Parameters: bytes: Uint8Array Returns: PrivateKey Defined in: @nimiq/core/types/wasm/web.d.ts:1702 Properties: serializedSize: readonly number Defined in: @nimiq/core/types/wasm/web.d.ts:1723 PURPOSE_ID: readonly static number Defined in: @nimiq/core/types/wasm/web.d.ts:1721 SIZE: readonly static number Defined in: @nimiq/core/types/wasm/web.d.ts:1722 Methods: equals(other: PrivateKey): boolean Description: Returns if this private key is equal to the other private key. Parameters: other: PrivateKey Returns: boolean Defined in: @nimiq/core/types/wasm/web.d.ts:1720 free(): void Returns: void Defined in: @nimiq/core/types/wasm/web.d.ts:1686 serialize(): Uint8Array Description: Serializes the private key to a byte array. Returns: Uint8Array Defined in: @nimiq/core/types/wasm/web.d.ts:1706 toHex(): string Description: Formats the private key into a hex string. Returns: string Defined in: @nimiq/core/types/wasm/web.d.ts:1716 static deserialize(bytes: Uint8Array): PrivateKey Description: Deserializes a private key from a byte array. Throws when the byte array contains less than 32 bytes. Parameters: bytes: Uint8Array Returns: PrivateKey Defined in: @nimiq/core/types/wasm/web.d.ts:1696 static fromHex(hex: string): PrivateKey Description: Parses a private key from its hex representation. Throws when the string is not valid hex format or when it represents less than 32 bytes. Parameters: hex: string Returns: PrivateKey Defined in: @nimiq/core/types/wasm/web.d.ts:1712 static generate(): PrivateKey Description: Generates a new private key from secure randomness. Returns: PrivateKey Defined in: @nimiq/core/types/wasm/web.d.ts:1690 ``` -------------------------------- ### API: Create New Nimiq Client Instance Source: https://www.nimiq.com/developers/build/web-client/reference/classes/Client A static method that creates a new Nimiq Client instance. The client automatically begins connecting to the network upon creation. It requires a configuration object. ```APIDOC static create( config: PlainClientConfiguration ): Promise ``` -------------------------------- ### Configure Nimiq Node Validator Keys Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator TOML configuration for setting up the validator address and various private keys (signing, voting, fee) in the `[validator]` section of the Nimiq node's `client.toml`. This includes placeholders for generated keys and an option for automatic reactivation. ```toml [validator] validator_address = "NQXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX" signing_key_file = "signing_key.dat" voting_key_file = "voting_key.dat" fee_key_file = "fee_key.dat" signing_key = "Schnorr Private Key" fee_key = "Schnorr Private Key" voting_key = "BLS Private Key" automatic_reactivate = true ``` -------------------------------- ### Nimiq ClientConfiguration Class API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/classes/ClientConfiguration Detailed API documentation for the `ClientConfiguration` class, including its constructor and methods for configuring a Nimiq client for web environments. This class allows setting network parameters, peer counts, logging levels, and sync modes. ```APIDOC Class: ClientConfiguration Description: Use this to provide initialization-time configuration to the Client. This is a simplified version of the configuration that is used for regular nodes, since not all configuration knobs are available when running inside a browser. Defined in: @nimiq/core/types/wasm/web.d.ts:967 Constructors: Constructor: new ClientConfiguration() Description: Creates a default client configuration that can be used to change the client's configuration. Use its `instantiateClient()` method to launch the client and connect to the network. Returns: ClientConfiguration Methods: build(): PlainClientConfiguration Description: Returns a plain configuration object to be passed to `Client.create`. Returns: PlainClientConfiguration desiredPeerCount(desired_peer_count: number): void Description: Sets the desired number of peers the client should try to connect to. Default is `12`. Parameters: desired_peer_count: number Returns: void free(): void Description: (No description provided) Returns: void logLevel(log_level: string): void Description: Sets the log level that is used when logging to the console. Possible values are 'trace' | 'debug' | 'info' | 'warn' | 'error'. Default is 'info'. Parameters: log_level: string Returns: void network(network: string): void Description: Sets the network ID the client should use. Input is case-insensitive. Possible values are 'MainAlbatross' | 'TestAlbatross' | 'DevAlbatross'. Default is 'MainAlbatross'. Parameters: network: string Returns: void onlySecureWsConnections(only_secure_ws_connections: boolean): void Description: Sets whether the client should only connect to secure WebSocket connections. Default is `true`. Parameters: only_secure_ws_connections: boolean Returns: void peerCountMax(peer_count_max: number): void Description: Sets the maximum number of peers the client should connect to. Default is `50`. Parameters: peer_count_max: number Returns: void peerCountPerIpMax(peer_count_per_ip_max: number): void Description: Sets the maximum number of peers the client should connect to per IP address. Default is `10`. Parameters: peer_count_per_ip_max: number Returns: void peerCountPerSubnetMax(peer_count_per_subnet_max: number): void Description: Sets the maximum number of peers the client should connect to per subnet. Default is `10`. Parameters: peer_count_per_subnet_max: number Returns: void seedNodes(seeds: any[]): void Description: Sets the list of seed nodes that are used to connect to the Nimiq Albatross network. Each array entry must be a proper Multiaddr format string. Parameters: seeds: any[] Returns: void syncMode(sync_mode: string): void Description: Sets the sync mode that shoud be used. Only \"light\" and \"pico\" are supported for web clients. Default is \"light\". Parameters: sync_mode: string Returns: void ``` -------------------------------- ### clientconfiguration_onlySecureWsConnections API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the clientconfiguration_onlySecureWsConnections method, detailing its signature, parameters, and return type. ```APIDOC readonly clientconfiguration_onlySecureWsConnections: (a: number, b: number) => void a: number b: number ``` -------------------------------- ### API: Get Address Classname Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Retrieves the class name associated with a given address object. This function is likely used for internal type identification or debugging within the Nimiq Core WASM module. ```APIDOC address___getClassname: readonly address___getClassname: (a) => [number, number] Defined in: @nimiq/core/types/wasm/web.d.ts:2259 Parameters: a: number Returns: [number, number] ``` -------------------------------- ### APIDOC: vestingcontract_proofToPlain Function Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Documents the `vestingcontract_proofToPlain` function, detailing its parameters and return type for converting vesting contract proof data to a plain format. ```APIDOC vestingcontract_proofToPlain: Signature: (`a`, `b`) => [`number`, `number`, `number`] Defined in: @nimiq/core/types/wasm/web.d.ts:2509 Parameters: a: number b: number Returns: [`number`, `number`, `number`] ``` -------------------------------- ### client_getStaker API Documentation Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput API documentation for the client_getStaker method, detailing its signature, parameters, and return type. ```APIDOC readonly client_getStaker: (a: number, b: any) => any a: number b: any ``` -------------------------------- ### API Method: hash_computeNimiqArgon2d Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Provides API documentation for the hash_computeNimiqArgon2d method, detailing its signature, parameters, and return type within the Nimiq Core WASM module. ```APIDOC hash_computeNimiqArgon2d: Signature: `readonly` **hash_computeNimiqArgon2d**: (`a`, `b`, `c`, `d`, `e`, `f`) => [`number`, `number`, `number`, `number`] Defined in: @nimiq/core/types/wasm/web.d.ts:2477 Parameters: a: number b: number c: number d: number e: number f: number Returns: [number, number, number, number] ``` -------------------------------- ### API Method: es256publickey_new Source: https://www.nimiq.com/developers/build/web-client/reference/interfaces/InitOutput Provides API documentation for the es256publickey_new method, detailing its signature, parameters, and return type within the Nimiq Core WASM module. ```APIDOC es256publickey_new: Signature: `readonly` **es256publickey_new**: (`a`, `b`) => [`number`, `number`, `number`] Defined in: @nimiq/core/types/wasm/web.d.ts:2382 Parameters: a: number b: number Returns: [number, number, number] ``` -------------------------------- ### Register a New Nimiq Validator Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator This snippet demonstrates how to send a transaction to register a new validator on the Nimiq blockchain. It includes examples for both the ARPL command-line tool and a cURL JSON-RPC call, requiring validator, signing, and voting keys, along with a reward address. ```ARPL validator:new ``` ```bash curl 'http://localhost:8648' -H 'Content-Type: application/json' \ --data-raw '{"method": "sendNewValidatorTransaction", "params": ["", "", "", "", "", "", 0, "+0"], "jsonrpc": "2.0", "id": 1}' ``` -------------------------------- ### Configure Nimiq Node Sync Mode Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator Example TOML configuration snippet to set the Nimiq node's synchronization mode to 'history' within the `[consensus]` section of the `client.toml` file. Note that 'history' mode requires significantly more storage and can extend sync times. ```toml [consensus] sync_mode = "history" ``` -------------------------------- ### Convert and Validate UTF-8 Strings and Byte Arrays using Utf8Tools Source: https://www.nimiq.com/developers/build/nimiq-utils Demonstrates `Utf8Tools` for converting strings to UTF-8 byte arrays and back, validating UTF-8, and truncating strings by byte length. It shows practical examples for common UTF-8 manipulation tasks. ```typescript import { Utf8Tools } from '@nimiq/utils/utf8-tools' // Convert a string to a UTF-8 byte array const utf8Bytes = Utf8Tools.stringToUtf8ByteArray('Hello, world!') console.log(utf8Bytes) // Output: Uint8Array of UTF-8 bytes // Convert a UTF-8 byte array back to a string const utf8String = Utf8Tools.utf8ByteArrayToString(utf8Bytes) console.log(utf8String) // Output: 'Hello, world!' // Validate if a byte array is valid UTF-8 const isValid = Utf8Tools.isValidUtf8(utf8Bytes) console.log(isValid) // Output: true // Truncate a string to a specific byte length with an ellipsis const { result, didTruncate } = Utf8Tools.truncateToUtf8ByteLength('This is a long string.', 10) console.log(result) // Output: 'This is…' console.log(didTruncate) // Output: true ``` -------------------------------- ### Retire Nimiq Validator Source: https://www.nimiq.com/developers/build/set-up-your-own-node/becoming-a-validator The second transaction in the validator removal process, confirming the validator's permanent departure from the network. This step follows deactivation and precedes the final deletion. The cURL command allows for manual submission, requiring sender, validator, fee, and validity start height. ```ARPL validator:retire ``` ```bash curl 'http://localhost:8648' -H 'Content-Type: application/json' \ --data-raw '{\"method\": \"sendRetireValidatorTransaction\", \"params\": [\"\", \"\", 0, \"+0\"], \"jsonrpc\": \"2.0\", \"id\": 1}' ```