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

@aidpproject/aidpcoin-jswallet

v0.10.3

Published

Aidpcoin JavaScript wallet library

Downloads

31

Readme

aidpcoin-jswallet

Aidpcoin wallet library for JavaScript. Non-custodial. By default it interacts with the Aidpcoin blockchain using public RPC services from https://rpc.ting.finance/ for both testnet and mainnet. You are free to use any RPC-service you like, including your own. See section Run your own blockchain node for more info

EXPERIMENTAL.

This lib needs a lot of testing before being used in production. Only use on mainnet if you "play around". This lib supports EVR as well (see section at the end)

Example code

To run these code examples

  1. Create an empty npm project
  2. Install @aidpproject/aidpcoin-jswallet
  3. Create a .mjs file called index.mjs

Minimalistic example

import AidpcoinWallet from "@aidpproject/aidpcoin-jswallet";

AidpcoinWallet.createInstance({
   mnemonic: "horse sort develop lab chest talk gift damp session sun festival squirrel",
   network: "aidp-test"
})
   .then(wallet => wallet.getBalance())
   .then(console.log);

Some stuff you can do

import AidpcoinWallet from "@aidpproject/aidpcoin-jswallet";
const wallet = await AidpcoinWallet.createInstance({
  mnemonic:
    "horse sort develop lab chest talk gift damp session sun festival squirrel",
  network: "aidp-test",
});

//OK now you have your wallet

//Example, get your addresses
const addresses = wallet.getAddresses();

//Address objects contains meta data about addresses, such as path/private key
const addressObjects = wallet.getAddressObjects();
 
//Get assets the wallet holds (not including mempool transactions) 
const assets = await wallet.getAssets();

//Get balance of base currency, like AIDP, not including mempool transactions
const balance = await wallet.getBalance();


const changeAddress = await wallet.getChangeAddress();
const receiveAddress = await wallet.getReceiveAddress();

const firstPrivateKey = wallet.getPrivateKeyByAddress(addresses[0]);

//History, is the list of deltas for all the addresses in this wallet
const history = await wallet.getHistory();

//Get this wallets entries in the mempool right now
const mempool = await wallet.getMempool();
 
//Example send and print out the id, will throw exception if fails
const sendResult = await wallet.send({
  toAddress: "muTv54qzXc6ozEc1RH2JbM92jzpBtVJBbw",
  amount: 1,
});
console.log(sendResult.transactionId);

Configure to use with your local node

In this example we run a local node in testnet mode, and RPC port is set to 8888

const wallet = await AidpcoinWallet.createInstance({
    mnemonic,
    network: "aidp-test",
    rpc_password: "mypassword",
    rpc_username: "myuser",
    rpc_url: "http://localhost:8888",
  });

Send AIDP and ASSETS

//index.mjs very important that file extension is .mjs
import AidpcoinWallet from "@aidpproject/aidpcoin-jswallet";

//This wallet belongs to account "Crazy Cat" on https://testnet.ting.finance/signin/
const options = {
  mnemonic:
    "mesh beef tuition ensure apart picture rabbit tomato ancient someone alter embrace",
  network: "aidp-test",
};
const wallet = await AidpcoinWallet.createInstance(options);
const addy = await wallet.getReceiveAddress();
console.log("My receive address", addy);

//Send 100 AIDP to Barry Crump on https://testnet.ting.finance/
await wallet.send({
  //Send 100 AIDP
  toAddress: "mhBKhj5FxzBu1h8U6pSB16pwmjP7xo4ehG",
  amount: 100,
  assetName:"AIDP",
});

//Send 313 BUTTER tokens to Barry Crump on https://testnet.ting.finance/
const transactionId = await wallet.send({
  assetName: "BUTTER",
  amount: 313,
  toAddress: "mhBKhj5FxzBu1h8U6pSB16pwmjP7xo4ehG",
});
console.log("Sending", transactionId);

Send many

//index.mjs very important that file extension is .mjs
import AidpcoinWallet from "@aidpproject/aidpcoin-jswallet";

//This wallet belongs to account "Crazy Cat" on https://testnet.ting.finance/signin/
const options = {
  mnemonic:
    "mesh beef tuition ensure apart picture rabbit tomato ancient someone alter embrace",
  network: "aidp-test",
};
const wallet = await AidpcoinWallet.createInstance(options);

//Send asset BUTTER to multiple recipients
const result = await wallet.sendMany({
  assetName: "BUTTER",
  outputs: {
    muTv54qzXc6ozEc1RH2JbM92jzpBtVJBbw: 1,
    mhWahrbRX6xBBrRjCo6ZkazaugXftD1CbM: 2,
  },
});

console.log("Sending", result.transactionId);

Evrmore

To support EVR instead of AIDP Create an instance of wallet and set baseCurrency

wallet.setBaseCurrency("EVR");

API

When you create your instance of a wallet you can specify some stuff.

You can set network to be something else than AIDP, for example EVR.

You can specify your own RPC node URL and username/password.

export interface IOptions {
    mnemonic: string;
    network?: ChainType; (that is "aidp" | "aidp-test" | "evr" | "evr-test")
    rpc_username?: string;
    rpc_password?: string;
    rpc_url?: string;
}

Check the TypeScript definitions for all the details

Run your own blockchain node

If you want to run your own internet exposed Node, checkout our RPC proxy. With RPC proxy and Cloudlare you can get a secure endpoint like https://rpc.mydomain.com/rpc checkout

  • https://github.com/aidpproject/aidpcoin-rpc-proxy
  • https://www.cloudflare.com/products/tunnel/

Advanced - pure RPC

You have access to the underlaying RPC function, wallet.rpc. See example

import AidpcoinWallet from "@aidpproject/aidpcoin-jswallet";
async function main(){
  const wallet = await AidpcoinWallet.createInstance({
    mnemonic: "horse sort develop lab chest talk gift damp session sun festival squirrel",
    network: "aidp-test",
  });
  const blockhash = await wallet.rpc("getbestblockhash", []);
  const block = await wallet.rpc("getblock", [blockhash]);
  console.log(block);
}
main();