Thor Model Kit
Deprecated, use thor-devkit instead.
Typescript library defines VeChain Thor data models, to aid DApp development.
Installation
npm i --save thor-model-kit
Usage
All widgets are as below:
Basic types
let addr = Addressconsole// 0x7567d83b7b8d80addcb281a71d54fc7b3364ffedconsole// vx:7567d83b7b8d80addcb281a71d54fc7b3364ffed let b32 = Bytes32console// 0xda90eaea52980bc4bb8d40cb2ff84d78433b3b4a6e7d50b75736c5e3e77b71ec let bi = BigIntconsole// 123
Crypto methods
let hash = console// 0x256c83b297114d201b30179f3f0ef0cace9783622da5974326b436178aeef610 hash = console// 0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad // Secp256k1let privKey = Secp256k1let pubKey = Secp256k1let addr = Secp256k1let signature = Secp256k1let recoveredPubKey = Secp256k1
Mnemonic & Keystore
// generate BIP39 mnemonic words, default to 12 words(128bit strength)let words = Mnemonic // derive private key from mnemonic words according to BIP32, using the path `m/44'/818'/0'/0/0`.// defined for VET at https://github.com/satoshilabs/slips/blob/master/slip-0044.mdlet privateKey = Mnemonic // in recovery process, validation is recommendedlet ok = Mnemonic // encrypt/decrypt private key using Ethereum's keystore schemelet keystore = await Keystore // throw for wrong passwordlet recoveredPrivateKey = await Keystore // roughly check keystore formatlet ok = Keystore
Transaction codec
let clauses = clauses: to: Address value: BigInt data: Buffer // calc intrinsic gaslet gas = Transactionconsole// 21000 let body: TransactionBody = chainTag: 0x9a blockRef: Buffer expiration: 32 clauses: clauses gasPriceCoef: 128 gas: BigInt dependsOn: null nonce: BigInt reserved: let tx = bodytxsignature = Secp256k1 let raw = txlet decoded = Transaction
License
thor-model-kit is licensed under the GNU Lesser General Public License v3.0, also included in LICENSE file in repository.