R5 Network
WebsiteR5 LabsGitHub
  • Getting Started
    • Hello & Welcome!
  • About R5
    • Overview
    • R5 Components
    • Consensus Mechanism
    • zkNet (Privacy)
  • R5 Coin
  • R5 Tokenomics
  • Tutorials & Guides
    • Connect & Use R5
      • R5 Desktop Wallet
      • MetaMask
      • Rabby Wallet
      • Coinbase Wallet
    • zkNet Web Wallet
    • R5 Desktop Wallet
      • Interface Overview
      • Send a Transaction
      • Receive a Transaction
      • Backup Your Wallet
      • Retrieve Your Private Key
    • How To: Deploy a Node
    • How To: Mine R5
    • How To: GPU Mine R5
    • How To: Build R5 From Source
    • How To: Connect Nodes Over LAN
  • For Developers
    • R5 SDK
      • R5 Relayer
      • R5 Console
      • JS Console
      • CLI Wallet
      • SCdev
      • SSL Proxy
    • Hardware Requirements
    • R5 Testnet
    • R5 Devnet
    • Local Networks
    • RPC API
      • admin
      • debug
      • ethash
      • miner
      • net
      • r5 (eth)
      • rpc
      • txpool
      • web3
    • R5 Analytics API
    • zkNet API
    • Node Configuration
    • Ethash-R5
    • Smart Contracts
    • Wrapped R5 (Native)
    • Tokens & NFTs
  • Bug Bounty Program
  • Resources
    • Website
    • R5 Labs
    • R5 Core Repository
Powered by GitBook
On this page
  • How to Launch the JS Console
  • What You Can Do in the JS Console
  • Example Usage
  • Security Considerations
  1. For Developers
  2. R5 SDK

JS Console

The R5 JS Console provides a powerful interactive JavaScript environment that connects directly to your local R5 node. Unlike the R5 Console—which accesses the node over HTTP via JSON‑RPC—the JS Console gives you full access to all RPC API namespaces by default, including sensitive ones such as admin, miner, and debug. This enables you to perform detailed node management and debugging directly from an interactive prompt.

How to Launch the JS Console

To start the R5 JS Console, run your R5 node with the R5 Relayer, and once you have your node running, use the following command:

./r5 --jsconsole

This command automatically attaches you to the node’s JavaScript runtime without requiring an additional "attach" flag. Once started, you will see an interactive prompt where you can execute JavaScript commands and directly access every available RPC API namespace.

If you are using a custom IPC path, or are having issues with starting the JS Console, you can try bypassing the relayer with the following command:

./r5 --bypass attach <ipc_path>

What You Can Do in the JS Console

The JS Console gives you complete control over your node, allowing you to:

  • Access All Namespaces: You have immediate access to all RPC API namespaces (e.g. admin, miner, debug, eth, web3, and net). This is particularly useful for developers and node operators who need to perform in-depth administration, debugging, or performance analysis.

  • Full Administrative Control: Execute administrative commands such as adding or removing peers, changing mining parameters, or retrieving detailed node information via the admin namespace.

  • Advanced Debugging and Profiling: Use the debug namespace endpoints to trace transactions, dump block data, generate performance profiles, and inspect memory usage.

  • Mining Management: Control the mining process directly using endpoints in the miner namespace, including starting or stopping mining and adjusting mining settings.

  • Standard Blockchain Operations: Perform standard blockchain queries (e.g. account balances, block data, transaction receipts) using the eth namespace, fully compatible with EVM dapps.

  • Utility Functions: Utilize web3 functions for data conversion (e.g. ASCII, UTF‑8, hexadecimal, wei conversions) to ease application development.

Example Usage

At the interactive prompt, you can run commands like:

// Check the current block number
eth.getBlockNumber();

// Retrieve node information from the admin namespace
admin.getNodeInfo(function(err, info) {
  if (err) { console.error(err); return; }
  console.log(info);
});

// Start mining with 2 threads
miner.start(2);

// Convert a string to hex using web3
let hexValue = web3.fromAscii("Hello, R5!");
console.log(hexValue);

Security Considerations

While the JS Console provides powerful access to all namespaces, including sensitive ones, it is intended for use in a secure, local development environment. Be cautious when using administrative or debugging commands, as they can affect node performance and security.

PreviousR5 ConsoleNextCLI Wallet

Last updated 1 month ago