0.1.0 • Published 2 years ago

thor-jsonrpc-server v0.1.0

Weekly downloads
-
License
LGPL-3.0
Repository
github
Last release
2 years ago

thor-jsonrpc-server

A local server that implements ETH JSON-RPC APIs for interacting with the VeChain Thor protocol.

Installation

npm i thor-jsonrpc-server

Usage

import { ThorJsonRPCServer } from 'thor-jsonrpc-server';
import { SimpleWallet } from '@vechain/connex-driver';

const wallet = new SimpleWallet();
// Add private key
wallet.import(key);

const srv = new ThorJsonRPCServer(
  url, // Node url, e.g., 
       // Solo node: 	http://127.0.0.1:8669
       // Main net: 	https://sync-mainnet.veblocks.net/	
       // Test net: 	https://sync-testnet.veblocks.net/
  wallet
);

// start the server with a given port
srv.start(port);

Example

  • Request:
{
  "id":1,
  "jsonrpc": "2.0",
  "method":"eth_blockNumber"
}
  • Response
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0x23"
}

License

This software is licensed under the GNU Lesser General Public License v3.0, also included in LICENSE file in repository.