Git Product home page Git Product logo

thor-model-kit's Introduction

Thor Model Kit

Typescript library defines VeChainThor data models.

Install

npm install --save thor-model-kit

Usage

basic types

import { Address, Bytes32, BigInt } from 'thor-model-kit'

let addr = Address.fromHex('0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', '0x' /* defaults to '0x' */)
console.log(addr.toString('0x' /* defaults to '0x' */)) 
console.log(addr.toString('vx:')) 

let b32 = Bytes32.fromHex('0xda90eaea52980bc4bb8d40cb2ff84d78433b3b4a6e7d50b75736c5e3e77b71ec', '0x' /* defaults to '0x' */)
console.log(b32.toString('0x' /* defaults to '0x' */)) 

let bi = BigInt.from(123)
console.log(b32.toString(10))

crypto

import { blake2b256, keccak256, Secp256k1 } from 'thor-model-kit'

transaction

import { Transaction } from 'thor-model-kit'

let body: Transaction.Body = {
    chainTag: 0x9a,
    blockRef: Buffer.from('0000000000000000', 'hex'),
    expiration: 32,
    clauses: [{
        to: Address.fromHex('7567d83b7b8d80addcb281a71d54fc7b3364ffed', ''),
        value: BigInt.from(10000),
        data: Buffer.alloc(0)
    }],
    gasPriceCoef: 128,
    gas: BigInt.from(21000),
    dependsOn: null,
    nonce: BigInt.from(12345678),
    reserved: []
}

let tx = new Transaction(body)

License

thor-model-kit is licensed under the GNU Lesser General Public License v3.0, also included in LICENSE file in repository.

thor-model-kit's People

Contributors

qianbin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.