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

smileycoinjs

v1.0.1

Published

A javascript api for interacting with a Smileycoin node

Downloads

8

Readme

Smileycoinjs

This package provides an API for interacting with a Smileycoin node(or supposedly any other node for that matter). This makes communication with a wallet using JavaScript much easier for you, by providing the API for most operations.

One possible use case could be to design a browser-based wallet of sorts, and include whatever information you want there.

How to use

First of all you have to have access to a running Smileycoin node. Information on how to build Smileycoin on your machine can be found here. You will have to run smileycoind.exe, or figure out how to run your node on cloud services.

const { Client } = require('smileycoinjs');

const smly = new Client({
    username: 'your rpcusername',
    password: 'your rpcpassword',
    url: 'the url to your node'
})

Sending funds

smly.send("<smileycoin address>", amount)
    .then((result) => {
        var info = JSON.parse(result);
        if(!info.error) console.log("Transaction successful!");
        else console.log("Transaction failed");
    })
    .catch((err) => {
        console.error(err);
    })

or the async method:

async function sendFunds(){
    let results;
    try {
        results = await smly.send("<smileycoin address>", amount);
    } catch(err) {
        console.error(err);
    }

    if(results && !results.error) console.log("Transaction successfull");
    else console.log("Transaction failed"); 
}

Create raw transaction

By getting values directly from listunspent, but may also just be hardcoded:

async function createRaw(){
    let unspent;
    try {
        unspent = await smly.listUnspent();
    } catch (err){
        unspent = null;
    }
    unspent = JSON.parse(unspent);
    var output = unspent.result;

    // Construct the outputs
    var transactions = [{
        txid: output[0].txid,
        vout: output[0].vout
    }];

    // Construct the inputs
    var addresses = {};
    addresses[output[0].address] = output[0].amount - 12;
    addresses[<address>] = 10;
    
    let result;
    try {
        result = await smly.createRawTransaction(transactions, addresses);
    } catch(err){
        console.log(err);
    }

    var info = JSON.parse(result);
    if(info && !info.error) console.log("createrawtransaction success - hexstring: " + info.result);
    else console.log("createrawtransaction failed - " + info.error);
}

Sign raw transaction

async function signRawTransaction(){
    let result;
    try { 
        result = await smly.signRawTransaction("<hexstring>")
    } catch(err){
        console.log("signrawtransaction failed - " + err);
    }
    var info = JSON.parse(result);
    if (info && !info.error) console.log("signrawtransaction successful - " + info.result);
    else console.log("signrawtransaction failed");
}

Send raw transaction

async function sendRawTransaction(){
    let result;
    try {
        result = await smly.sendRawTransaction("<hexstring from signing>");
    } catch (err) {
        console.error(err);
    }

    var info = JSON.parse(result);
    if(info && !info.error) console.log("Raw transaction sent successfully - " + info.result);
    else console.log("Raw transaction unsuccessful");
}

Generating a new address

smly.getNewAddress("<account>")
    .then((result) => {
        var info = JSON.parse(result);
        if(!info.error) console.log("New address generated successfully!");
        else console.log("Generating new address unsuccessful");
    })
    .catch(err => {
        console.error(err);
    });
smly.getNewAddress()
    .then((result) => {
        var info = JSON.parse(result);
        if(!info.error) console.log("New address generated successfully!");
        else console.log("Generating new address unsuccessful");
    })
    .catch(err => {
        console.error(err);
    });

More usage examples can be found in the test file

API commands

Supported operations at this point:

  • getinfo
  • getblockchaininfo
  • getnetworkinfo
  • getmininginfo
  • getconnectioncount
  • getbestblockhash
  • getblock "hash" ( verbose )
  • getblockcount
  • getblockhash index
  • getdifficulty
  • ping
  • dumpprivkey "smileycoinaddress"
  • dumpwallet "filename"
  • getaccount "smileycoinaddress"
  • getaddressesbyaccount "account"
  • getaccountaddress "account"
  • getbalance ( "account" minconf )
  • getunconfirmedbalance
  • getwalletinfo
  • getnewaddress ( "account" )
  • getreceivedbyaccount "account" ( minconf )
  • getreceivedbyaddress "smileycoinaddress" ( minconf )
  • listreceivedbyaccount ( minconf includeempty )
  • listreceivedbyaddress ( minconf includeempty )
  • listaccounts ( minconf )
  • listunspent ( minconf maxconf ["address",...] )
  • settxfee amount
  • gettransaction "txid"
  • getrawtransaction "txid" ( verbose )
  • sendtoaddress "address" amount
  • sendfrom "fromaccount" "tosmileycoinaddress" amount ( minconf "comment" "comment-to" )
  • sendmany "fromaccount" {"address":amount,...} ( minconf "comment" )
  • listtransactions ( "account" count from )
  • verifymessage "smileycoinaddress" "signature" "message"
  • validateaddress "smileycoinaddress"
  • createrawtransaction
  • signrawtransaction
  • sendrawtransaction
  • signmessage "smileycoinaddress" "message"

TODO:

Operations that have not been implemented:

  • addmultisigaddress nrequired ["key",...] ( "account" )
  • addnode "node" "add|remove|onetry"
  • backupwallet "destination"
  • createmultisig nrequired ["key",...]
  • decoderawtransaction "hexstring"
  • decodescript "hex"
  • encryptwallet "passphrase"
  • getaddednodeinfo dns ( "node" )
  • getblocktemplate ( "jsonrequestobject" )
  • getgenerate
  • gethashespersec
  • getnettotals
  • getpeerinfo
  • getrawchangeaddress
  • getrawmempool ( verbose )
  • getrichaddresses
  • gettxout "txid" n ( includemempool )
  • gettxoutsetinfo
  • getwork ( "data" )
  • help ( "command" )
  • importprivkey "smileycoinprivkey" ( "label" rescan )
  • importwallet "filename"
  • keypoolrefill ( newsize )
  • listaddressgroupings
  • listlockunspent
  • listsinceblock ( "blockhash" target-confirmations )
  • lockunspent unlock [{"txid":"txid","vout":n},...]
  • move "fromaccount" "toaccount" amount ( minconf "comment" )
  • setaccount "smileycoinaddress" "account"
  • setgenerate generate ( genproclimit )
  • submitblock "hexdata" ( "jsonparametersobject" )
  • verifychain ( checklevel numblocks )