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

@cwv/cwv.js

v1.4.3

Published

CWV Chain JavaScript API & SDK

Downloads

13

Readme

cwv.js


Install

$ npm install @cwv/cwv.js

Super simple to use

Setting up the network,cwv support network has testnet and prodnet

const cwv=require('@cwv/cwv.js');
var rp = require('request-promise')
//set testnet network type
cwv.config.server_base='http://ta30.icwv.co:38000/fbs';
cwv.config.net_type='testnet'
//set prodnet network type
cwv.config.server_base='http://chain.cwv.one/block';
cwv.config.net_type='prodnet'
cwv.config.rpc_provider = rp;

Get balance and nonce

const cwv=require('@cwv/cwv.js');
cwv.rpc.getBalance('8f3aa4f0f35ff81ba487f91f6b980c0ba2562245').then(function(result){
    console.log(result.account.balance)
    console.log(result.account.nonce)
})

Get block info by hash

const cwv=require('@cwv/cwv.js');
cwv.rpc.getBlockByHash('03a15d84e6e29d2affab1ddc680f0aefc20586bd73ea3d81dcf6505924cfb86c').then(function(result){
    console.log(result)
})

Get block info by height

const cwv=require('@cwv/cwv.js');
cwv.rpc.getBlockByNumber('1518059').then(function(result){
    console.log(result)
})

Get the current height of the CWV blockchain

const cwv=require('@cwv/cwv.js');
cwv.rpc.getBlockByMax().then(function(result){
    console.log(result)
})

Create keystore.json、keypair

const cwv=require('@cwv/cwv.js');
const fs=require('fs');
var kp = cwv.KeyPair.genRandomKey();
var json = keystore.exportJSON(kp,"000000");
let fd = fs.openSync('keystore.json', 'w+');
fs.writeSync(fd,JSON.stringify(json));
console.log('keypair',kp);

Send transfer,support balance transfer,token transfer, crypto token transfer 。

const cwv=require('@cwv/cwv.js');
var kp = cwv.KeyPair.genFromPrikey(
  '89611e9ed751b2bb0f2a84d1b364bd6ef97a512a7ad0b1b50241168ff3add985')
/**
* transfer
* @param {*} from {"keypair":{"address":"","privateKey":"",nonce:10}}
* @param {*} exdata Plaintext
* @param {*} args 
* 	transfer balance
* 	args=[{"address":"","amount":100},{"address":"", "amount":20}]
* 
* 	transfer token
* 	args=[
* 		{"address":"","token":"AAA","tokenAmount":1000},
* 		{"address":"","token":"AAA","tokenAmount":2000}
*		]
* 
* 	transfer crc721 token
* 	args=[
* 		{"address":"","symbol":"house","cryptoToken":["hash0","hash1"]},
* 		{"address":"","symbol":"house","cryptoToken":["hash2","hash3"]}
* 	]
*/
kp.nonce=10;
var from={keypair:kp};
var args=[{"address":"066c03fcc3048863f72b051530e5a212fb9233f6","amount":1}]
cwv.rpc.transfer(from,exdata,args).then(function(result){
    console.log(result)
})

Get transaction information through transaction hash

const cwv=require('@cwv/cwv.js');
cwv.rpc.getTransaction('f9bea09140e8e2eb2956976c3373418e2a935d821732d86bce33117d17314088').then(function(result){
    console.log(result)
})

Create a token transaction

const cwv=require('@cwv/cwv.js');
/**
* create token
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} exdata Plaintext
* @param {*} args {"token":"AAA", "amount":10000000000000000000000000000,"opCode":0}
*/
cwv.rpc.publicToken(from, exdata, args).then(function(result){
    console.log(result)
})

Burn a token transaction

const cwv=require('@cwv/cwv.js');
/**
* burn token
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} exdata Plaintext
* @param {*} args {"token":"AAA", "amount":10000000000000000000000000000,"opCode":1}
*/
cwv.rpc.burnToken(from,exdata,args).then(function(result){
    console.log(result)
})

Additional a token transaction

const cwv=require('@cwv/cwv.js');
/**
* Additional token
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} exdata Plaintext
* @param {*} args {"token":"AAA", "amount":10000000000000000000000000000,"opCode":2}
*/
cwv.rpc.mintToken(from,exdata,args).then(function(result){
    console.log(result)
})

Create contract

const cwv=require('@cwv/cwv.js');
/**
* createContract
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} exdata Plaintext
* @param {*} args {"data":"", "amount":""}
*/
cwv.rpc.createContract(from,exdata,args).then(function(result){
    console.log(result)
})

Call contract

const cwv=require('@cwv/cwv.js');
/**
* callContract
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} exdata Plaintext
* @param {*} args {"contract":"", "data":"", "amount":""}
*/
cwv.rpc.callContract(from,exdata,args).then(function(result){
    console.log(result)
})

Create crc721 token transaction

const cwv=require('@cwv/cwv.js');
/**
* create CRC721 token
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} exdata Plaintext
* @param {*} args {"total":10, "symbol":"", "code":"","name":"",key:[],value:[]}
*/
cwv.rpc.createCrypto(from,exdata,args).then(function(result){
    console.log(result)
})

signEvfsFileUpload sign

const cwv=require('@cwv/cwv.js');
/**
* get evfs file upload sign
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} args {"evfs":""}
*/


var result=cwv.rpc.signEvfsFileUpload(from, exdata, args)

Return structure
{
    tx:""
}

signEvfsAuthFile

const cwv=require('@cwv/cwv.js');
/**
* get evfs auth sign
* @param {*} from {"keypair":{"address":"","privateKey":""}, "nonce": 0}
* @param {*} args {"fileHash":"","addAddrs":["",""]}  //add auth list
									{"fileHash":"","removeAddrs":["",""]} //remove auth list
*/
var result=cwv.rpc.signEvfsAuthFile(from, exdata, args)

Return structure
{
    tx:""
}

signCustom

const cwv=require('@cwv/cwv.js');
/**
* get evfs auth sign
* @param {*} from {"keypair":{"address":"","privateKey":""}}
* @param {*} args {data:""}
*/
cwv.rpc.signCustom(from, exdata, args)

License

MIT