A web3 adaptor for VeChain Thor RESTful API.
Table of contents
- Install
- Usage
- Web3 method supported
- Send transaction
- Documentation
- Play with multi-clause
- Which Stack Should I Choose Regarding Connex,Thorify And Web3-Gear
- FAQ
- Notes
- Compatibility
- Debugging
- License
Install
npm install --save thorify
npm install --save [email protected]* # Web3 is needed as 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
Below is an reference when you are planning your technical stack: Here are some most common scenarios: VTHO is a token that compatible with VIP180(ERC-20), you can build a contract instance using It's done by calling the functions of prototype contract, check wiki page for detailed info about prototype contract. 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. Currently, This project is licensed under the MIT license, Copyright (c) 2017 VeChain Foundation. For more information see LICENSE.md.
web3.eth.sendTransaction()
contract.deploy.send()
contract.methods.myMethod.send()
Documentation
Play with multi-clause
Which Stack Should I Choose Regarding Connex,Thorify And Web3-Gear
Connex
+ Connex powered VeChain walletsThorify + Web3
Web3 + Web3-Gear
Web3 + Web3-Gear
FAQ
How do I send VTHO token
web3
and do what ever you want.
0x0000000000000000000000000000456E65726779
Multi party payment protocol or sponsored contract
Method not supported
Notes
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
Thorify
is compatible with [email protected]*
.
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