npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vechain/sdk-rpc-proxy

v1.0.0-rc.2

Published

Proxy Thor's RESTful API to Eth JSON-RPC

Downloads

238

Readme

@vechain/sdk-rpc-proxy

Welcome to the RPC Proxy of the VeChain SDK!

Introduction

The RPC Proxy is designed to bridge the gap between Thor's RESTful API and Ethereum's JSON-RPC, enabling seamless interaction with the VeChainThor blockchain through RPC calls. It is particularly useful for integrating with tools such as the Remix IDE.

Installation

To install the RPC proxy, use the following command:

yarn add @vechain/sdk-rpc-proxy

Usage

The RPC proxy is simple to use. To start it, run:

npx rpc-proxy

By default, the proxy is configured to be used with a solo node running on your local machine. There are two options if you want to change the default behavior, or use a custom configuration:

  • Create a config.json file and pass it to the command when launching the RPC Proxy.
  • Use CLI options.

Configuration file

Run:

npx rpc-proxy -c <json config file>

Or:

npx rpc-proxy --configurationFile <json config file>

CLI Options

With rpc-proxy, you can use the following CLI options. Cli options override the configuration file. So you can run the rpc-proxy with:

  • a configuration file with the default values and override them with the cli options

    • -e.g.- npx rpc-proxy -p 8545 -v ...
  • a custom configuration file and override some values with the cli options

    • -e.g.- npx rpc-proxy -c /path/of/custom-config.json -p 8545 -v ...

Cli options list

Give the configuration file

  • -c, --configurationFile <config>: The path to the configuration file.

    • -e.g.- npx rpc-proxy -c /path/of/custom-config.json OR rpc-proxy --configurationFile custom-config.json
  • -p, --port <port>: The port on which the proxy server will run.

    • -e.g.- npx rpc-proxy -p 8545 OR rpc-proxy --port 8545
  • -u, --url <url>: The URL of the VeChainThor node.

    • -e.g.- npx rpc-proxy -u http://testnet.vechain.org OR rpc-proxy --url http://testnet.vechain.org
  • -v, --verbose: Whether to enable verbose logging.

    • -e.g.- npx rpc-proxy -v OR rpc-proxy --verbose

Give the accounts

  • -a, --accounts <accounts>: The accounts (private keys) that the proxy server will use to sign transactions. It is a space-separated list of private keys.

    • -e.g.- npx rpc-proxy -a "7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158" OR npx rpc-proxy --accounts "7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158"
  • -m, --mnemonic <mnemonic>: The mnemonic that the proxy server will use to sign transactions.

  • -mc, --mnemonicCount <mnemonicCount>: The number of accounts to derive from the mnemonic.

  • -mi, --mnemonicInitialIndex <mnemonicInitialIndex>: The index from which to start deriving accounts from the mnemonic.

    • -e.g.- npx rpc-proxy -m "denial kitchen pet squirrel other broom bar gas better priority spoil cross" -mc 10 -mi 1 OR npx rpc-proxy --mnemonic "denial kitchen pet squirrel other broom bar gas better priority spoil cross" --mnemonicCount 10 --mnemonicInitialIndex 1
    • NOTE: --mnemonic, --mnemonicCount, and --mnemonicInitialIndex MUST be used together.

Use delegation

  • -e, --enableDelegation: Whether to enable delegation.
  • -dp, --delegatorPrivateKey <delegatorPrivateKey>: The private key of the delegator.
  • -du, --delegatorUrl <delegatorUrl>: The URL of the delegator.
    • -e.g.- npx rpc-proxy -e -dp 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158 OR npx rpc-proxy --enableDelegation --delegatorPrivateKey 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158
    • -e.g.- npx rpc-proxy -e -du https://sponsor-testnet.vechain.energy/by/... OR npx rpc-proxy --enableDelegation --delegatorUrl https://sponsor-testnet.vechain.energy/by/...
    • NOTE: --delegatorPrivateKey and --delegatorUrl are mutually exclusive.
    • NOTE: if --enableDelegation is used, --delegatorPrivateKey OR --delegatorUrl MUST be used.

Configuration file

The config.json file is used to configure the proxy server. It contains the following fields:

  • url: The URL of the VeChainThor node.
  • port: The port of the proxy server.
  • accounts: The accounts that the proxy server will use to sign transactions (can be a mnemonic or an array of private keys).
  • verbose: Wheter to enable verbose logging.
  • debug: Whether to enable debug mode.
  • enableDelegation: Whether to enable delegation.

Example Configurations

Simple thor solo configuration with mnemonic:

{
    "url": "http://127.0.0.1:8669",
    "port": 8545,
    "accounts": {
        "mnemonic": "denial kitchen pet squirrel other broom bar gas better priority spoil cross",
        "count": 10
    },
    "verbose": true,
    "enableDelegation": false
}

Simple thor solo configuration with accounts as a list of private keys:

{
    "url": "http://127.0.0.1:8669",
    "port": 8545,
    "accounts": [
        "7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158",
        "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158"
    ],
    "verbose": true,
    "enableDelegation": false
}

Simple testnet configuration with a delegator private key:

{
  "url": "https://testnet.vechain.org",
  "port": 8545,
  "accounts": {
    "mnemonic": "expire pair material agent north ostrich fortune level cousin snow mixture nurse",
    "count": 10,
    "initialIndex": 0
  },
  "delegator": {
    "delegatorPrivateKey": "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158"
  },
  "enableDelegation": true
}

Simple testnet configuration with a delegator private url:

{
  "url": "https://testnet.vechain.org",
  "port": 8545,
  "accounts": {
    "mnemonic": "expire pair material agent north ostrich fortune level cousin snow mixture nurse",
    "count": 10,
    "initialIndex": 0
  },
  "delegator": {
    "delegatorUrl": "https://sponsor-testnet.vechain.energy/by/..."
  },
  "enableDelegation": true
}

Run as Docker Container

To run the RPC proxy as a Docker container, follow these steps:

cd ../..
docker build -f docker/rpc-proxy/Dockerfile . -t vechain-rpc-proxy
# We are assuming that the config.json file is placed at the same level as the project root
docker run -d -p 8545:8545 -v ./config.json:/app/config.json -t vechain-rpc-proxy

If you do not pass a config.json file, the default solo network standard configuration will be used. Make sure to provide your desired configuration file.