BlueCefa DevKit
Typescript library to aid DApp development on BlueCefa
Installation
npm i --save blcf-devkit
Usage
import all components or some of them
Crypto methods
they are under cry
namespace
Hashing
let hash = cryconsole// 256c83b297114d201b30179f3f0ef0cace9783622da5974326b436178aeef610 hash = cryconsole// 47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
Secp256k1
let privKey = crysecp256k1let pubKey = crysecp256k1let addr = crylet signature = crysecp256k1let recoveredPubKey = crysecp256k1
Mnemonic & Keystore
// generate BIP39 mnemonic words, default to 12 words(128bit strength)let words = crymnemonic // derive private key from mnemonic words according to BIP32, using the path `m/44'/818'/0'/0`.// defined for VET at https://github.com/satoshilabs/slips/blob/master/slip-0044.mdlet privateKey = crymnemonic // in recovery process, validation is recommendedlet ok = crymnemonic // encrypt/decrypt private key using Ethereum's keystore schemelet keystore = await cryKeystore // throw for wrong passwordlet recoveredPrivateKey = await cryKeystore // roughly check keystore formatok = cryKeystore
RLP
// define the profile for tx clause structurelet profile: RLPProfile = name: 'clause' kind: name: 'to' kind: 20 name: 'value' kind: 32 name: 'data' kind: let clause = to: '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed' value: 10 data: '0x' let rlp = profile let data = rlpconsole// d7947567d83b7b8d80addcb281a71d54fc7b3364ffed0a80 let obj = rlp// `obj` should be identical to `clause`
Transaction
let clauses = to: '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed' value: 10000 data: '0x' // calc intrinsic gaslet gas = Transactionconsole// 21000 let body: TransactionBody = chainTag: 0x9a blockRef: '0x0000000000000000' expiration: 32 clauses: clauses gasPriceCoef: 128 gas: 21000 dependsOn: null nonce: 12345678 let tx = bodylet signingHash = crytxsignature = crysecp256k1 let raw = txlet decoded = Transaction
Certificate
supports client side self-signed certificate
let cert: Certificate = purpose: 'identification' payload: type: 'text' content: 'fyi' domain: 'localhost' timestamp: 1545035330 signer: <<<signer-address>>> let jsonStr = Certificatelet signature = secp256k1 certsignature = '0x' + signature Certificate // certificate idlet id = '0x' + cry
ABI
let fn = "constant": false "inputs": "name": "a1" "type": "uint256" "name": "a2" "type": "string" "name": "f1" "outputs": "name": "r1" "type": "address" "name": "r2" "type": "bytes" "payable": false "stateMutability": "nonpayable" "type": "function" let data = fn
License
blcf-devkit is licensed under the GNU Lesser General Public License v3.0, also included in LICENSE file in repository.