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

cryptocurve-sdk

v3.1.1

Published

CryptoCurve SDK provides a single, simple API for cross-chain (ETH, WAN) functionality

Downloads

15

Readme

CryptoCurve SDK

A single, simple API for cross-chain (ETH, WAN) functionality.

Installation

Browser

Download and include the script from our release page (or your local dist folder after building) in your HTML file and instantiate an instance as follows:

<script src="cryptocurve-sdk.min.js"></script>

node.js

npm install cryptocurve-sdk

Folders

  • bin: the compiled node.js application
  • dist: the browserfied script for web clients
  • examples: sample code to demonstrate usage
  • src: all source code

Building

npm run build runs tsc to compile from typescript into the bin/ folder, then browserify to compile into the dist/ folder, then uglify to minify the result.

Usage

After creating an instance of the SDK.Client class (see below for details), the following methods will be available:

sdk.setBlockchainNetwork(network);
sdk.setProvider(host, timeout, username, password);
sdk.sendTransaction(transaction, privateKey);

NOTE: either setBlockchainNetwork must be called or the transaction object must contain the network identifier, eg.

transaction.network = 'eth';

which can be eth for ethereum or wan for wanchain. If not supplied, the sending protocol will default to the ethereum network.

Additionally, web3.js objects and methods can be accessed via sdk.web3 or directly on the sdk object itself, eg.

sdk.eth.getCoinbase()

Utility methods are available from the SDK.utils library.

See examples folder, in particular samples.js which can be run from both browser (dynamic.html) and node.js (node dynamic). Please note that the samples required test accounts to be configured in the testAccounts.js file.

Configuring test accounts

Edit the accounts values at the top of the testAccounts.js file in the examples folder, you can create an Etheruem wallet here and a Wanchain wallet here.

To create a coinbase account, enter the console and run

// miner.setEtherbase(address) eg.
miner.setEtherbase("0x77f92a6b4b61319e538a6bc5345ad5eaab8d8654")

Browser

Include the script from our release page (or your local dist folder after building) in your HTML file and instantiate an instance as follows:

<script src="cryptocurve-sdk.js"></script>
<script type="text/javascript">
// if hostname is null, defaults to http://localhost:8545
var sdk = new window.cryptocurve.sdk.Client(hostname);
sdk.setProvider(hostname);

sdk.eth.getCoinbase()...
sdk.web3.eth.getCoinbase()...

var sdkUtils = window.cryptocurve.sdk.utils;
</script>

node.js

var CryptoCurveSDK = require('cryptocurve-sdk');
var sdk = new CryptoCurveSDK.Client();
var sdkUtils = new CryptoCurveSDK.utils;

sdk.eth.net.getId()...

Transactions

CryptoCurveSDK.Client.createTransaction returns a promise that resolves with the prepared transaction object:

sdk.createTransaction({...})
   .then(function(transaction){
       // ...
   });

NOTE: the SDK client must be connected as the transaction instance will update itself from the blockchain node.

The following methods are available on the Transaction instance:

  • setNetwork(network) network in ['eth', 'wan']
  • setChainId(id) / setNetworkId(id) a null id will retrieve the chain id from the client node
  • setReceiverAddress(to)
  • setSenderAddress(from)
  • setNonce(nonce) [null will retrieve the nonce from the client node]
  • setValue(value, denomination) denomination must be in selected blockchain's unit, eg. if network is 'wan' then denomination must be in wanchain units
  • setData(data)
  • setGasPrice(gasPrice) a null gasPrice will retrieve the price from the client node
  • setGasLimit(gasLimit) a null gasLimit will estimate the gas limit from the client node
  • validate() returns a promise that resolves if the transaction is ready and valid
  • signTransaction(privateKey) returns the transaction signed with the supplied private key

An SDK transaction instance can be identified by its generator property, which will always be 'cryptocurve-sdk':

if (transaction.generator === 'cryptocurve-sdk') {
    // ...
}

Utility library

(to be completed)

Wallet library

(to be completed)

Something missing?

Please let us know by opening issues or contributing!