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

thorify

v1.6.2

Published

A web3 adaptor for VeChain Thor RESTful HTTP API.

Downloads

7,504

Readme

Thorify    Gitter

NPM Version Build Status Coverage Status

A web3 adaptor for VeChain Thor RESTful API.

Table of contents

Install

npm i thorify web3@1.* # Web3 is needed as dependency.

Furthermore, if you would like to change web3 version after installation, for example 1.6, run npm i [email protected] [email protected] as subscriptions is a peer dependency.

Usage

// ES6 style
import { thorify } from "thorify";
const Web3 = require("web3");		// Recommend using require() instead of import here

const web3 = thorify(new Web3(), "http://localhost:8669");

web3.eth.getBlock("latest").then(res => console.log(res));
// Best block info will be displayed

If you would like to write code in ES5, check below for the initialization code.

// ES5 style
const thorify = require("thorify").thorify;
const Web3 = require("web3");

const web3 = thorify(new Web3(), "http://localhost:8669");

web3.eth.getBlock("latest").then(res => console.log(res));
// Best block info will be displayed

Web3 method supported

web3 instance
├── eth
│   ├── getBlockNumber
│   ├── getBalance
│   ├── getStorageAt
│   ├── getCode
│   ├── getBlock
│   ├── getTransaction
│   ├── getTransactionReceipt
│   ├── sendTransaction
│   ├── sendSignedTransaction
│   ├── call
│   ├── estimateGas
│   ├── getPastLogs
│   ├── subscribe
│   ├── clearSubscriptions
│   ├── getEnergy
│   ├── getChainTag
│   ├── getBlockRef
│   ├── accounts
│   └── Contract
│       ├── Constructor(new Contract())
│       ├── clone
│       ├── deploy
│       ├── methods
│       ├── methods.myMethod.call
│       ├── methods.myMethod.send
│       ├── methods.myMethod.estimateGas
│       ├── methods.myMethod.encodeABI
│       ├── events
│       ├── once
│       ├── events.myEvent
│       ├── events.allEvents
│       └── getPastEvents
└── utils

Send Transaction

In Thor official implementation , the client DOES NOT neither manage user's private-key/keyStore nor use private key to sign a Transaction. Unfortunately, thorify can not directly perform eth_sendTransaction but there is another way to sign a transaction.

In web3.js accounts, it gives the opportunity to add your private-key, stored in your runtime context (In Node.js context, it's stored in memory while in Browser context, it's stored in memory/local storage), to accounts module. When you are trying to send a transaction, the module will check the private key associated with from field. Once the private key and from have been matched, the module will sign the transaction. The APIs that follows the mechanism are:

  • web3.eth.sendTransaction()
  • contract.deploy.send()
  • contract.methods.myMethod.send()

Documentation

API Reference

Play with multi-clause

  1. thor-devkit.js supports multi-clause and sign transaction
  2. send signed transaction using sendSignedTransaction

Which Stack Should I Choose Regarding Connex,Thorify And Web3-Gear

  • Connex: The standard interface to connect VeChain apps with VeChain blockchain and user.
  • Web3-Gear: Proxy Thor's RESTful API to Eth's JSON-RPC, to support Remix, Truffle and more.

Below is an reference when you are planning your technical stack:

tech-stack

Here are some most common scenarios:

  1. Develop a web application: Connex + Connex powered VeChain wallets
  2. Backend service in Node.js: Thorify + Web3
  3. Contract development in Truffle: Web3 + Web3-Gear
  4. Contract development in Remix-IDE: Web3 + Web3-Gear

FAQ

How do I send VTHO token

VTHO is a token that compatible with VIP180(ERC-20), you can build a contract instance using web3 and do what ever you want.

Multi party payment protocol or sponsored contract

It's done by calling the functions of prototype contract, check wiki page for detailed info about prototype contract.

Method not supported

The RESTful API of Thor is different with Ethereum's JSON-RPC, therefore, there are some methods in web3 are not supported by thorify, feel free to open an issue discuss the features.

Notes

  • There are three special block number in Ethereum: earliest,latest,pending. In VeChain Thor, we introduced best block and there is no pending block, so they will be replaced with 0 (aka genesis), best, best

Compatibility

Currently, Thorify is compatible with web3@1.*, tested versions are 1.2~1.7.1.

Debugging

DEBUG=thor:* ts-node index.ts 

ts-node index.ts can be replaced with command to run your code, this example is only for Node.js environment. For more detailed info, please refer to debug.

License

This project is licensed under the MIT license, Copyright (c) 2017 VeChain Foundation. For more information see LICENSE.md.