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

bitofme

v1.0.7

Published

BitOfMe Client package to post/read contributions

Downloads

4

Readme

bitofme

npm package to access bitofme smart contracts written in typescript

Install module

npm install bitofme

Register a test ENS Name (only for ganache/rinkeby regions. Wont work with mainnet)

const ensName = "atestname";
await bitofme.registerENSName(ensName);

Setup ENSName for BitOfMe Rental

import {BitOfMeService, SubdomainCreationRule} from 'bitofme';

const bitofme = new BitOfMeService("rinkeby");
const ensName = "atestname";
const referralWallet = "0xYourAddressToReceiveCommissions";
const referralFeePPK = 20; //Parts per Kilo. For 1%, enter 10. For 1.5% enter 15. 2% is 20
await bitofme.createMasterAgreementStep1(ensName, SubdomainCreationRule.DeedOwnerOnly, referralWallet, referralFeePPK); //creates the contract
await bitofme.createMasterAgreementStep2(ensName); //grants ENS name ownership

Register a subdomain

const ensName = "atestname";
const subdomainName = "mysubdomain";
const receipientWallet = "0xWalletToReceiveFunds";
const adminWallet = "0xWalletThatCanInitiateRefunds";
const encryptionKeys = bitofme.generateKeyPair();
//Input fields separated by pipe. Optional fields enclosed by []. Dropdown questions end with the options in () separated by /
const inputFields = "name|[address]|can we send you email?(yes/no)";
const maxAllowedPayment = 1000;
const fiatCurrency = "usd";
const rentalContractAddress = await bitofme.createRentalAgreement(ensName, subdomainName, receipientWallet, adminWallet, encryptionKeys.publicKey, inputFields, maxAllowedPayment, fiatCurrency); //creates the contract
console.log("rentalContractAddres", rentalContractAddress);

Initiate payment

const ensFullName = "mano.invoice.eth";
const plainMessage = "Jack Frost|123 Main Street, TX|[email protected]|y";
const amount = 100.0;
const currencyCode = "usd";
const gasPrices = await bitofme.gasPriceEstimate();
const gasPriceGWeiForFastConfirmation = gasPrices.fastGWei;
const depositStatus = await bitofme.deposit(ensFullName, plainMessage, amount, currencyCode, gasPriceGWeiForFastConfirmation);
console.log(depositStatus);

Output:

true

Get encoded data for given input (to use with ledger nano s, trezor)

const ensFullName = "mano.invoice.eth";
const plainMessage = "Jack Frost|123 Main Street, TX|[email protected]|y";
const amount = 100.0;
const currencyCode = "usd";
const encodedData = await bitofme.encodeInputs(ensFullName, plainMessage, amount, currencyCode);
console.log(encodedData);

Output:

'0x53839ece0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000025800000000000000000000000000000000000000000000000000000000000000c23033333365656335383364303461353563653061626139646266623034303335653863366465346635303165636339623236633038666135303161356563313530376235336237316363653864646131623032346633663863373061303465643633306566666337383435363833313534626263623935626231323433343366376562633130643336613763366235323763366537666566386534316463653737396665616664653738366632626333303664323239663534613331646665303238000000000000000000000000000000000000000000000000000000000000'

Utility Functions

Generate encryption keypair

import {BitOfMeService} from 'bitofme';

const bitofme = new BitOfMeService("rinkeby");
const keyPair = bitofme.generateKeyPair();

console.log(keyPair); //Warning: Never print private key to console!

Output:

{publicKey: '022f7148edd46fb3ef945ff4974b3c8213b713f2ec12ae2d1bb82aeb67dffdfc36', privateKey: '0x6782433bb0d4dee50218531af18a089d54
78180a04f71a3d559a042c706a3c8c'}

Encrypt/Decrypt messages

let plainMessage = "hello world";

let encryptedMessage = bitofme.encrypt(plainMessage, keyPair.publicKey);
let decryptedMessage = bitofme.decrypt(encryptedMessage, keyPair.privateKey);
console.log('encryptedMessage', encryptedMessage);

Output:

'encryptedMessage', '0333eec583d04a55ce0aba9dbfb04035e8c6de4f501ecc9b26c08fa501a5ec1507b53b71cce8dda1b024f3f8c70a04ed634c1e3366ce9301e648350b127f2798df61183693301f566dda6718229c3a0967f1438bb98696f1a1b7160d7499e60e55'

Get selected Account at the injected provider (if Metamask not installed or locked, this will be "")

let selectedAccount = await bitofme.selectedAccount();
console.log("selectedAccount", selectedAccount);

Output:

Selcted account', '0x627306090abab3a6e1400e9345bc60c78a8bef57'

Get conversion rate

const rate = await bitofme.conversionRate("usd");
console.log(rate);

Output:

630.25

Get gas price estimates

const priceEstimate = await bitofme.gasPriceEstimate();
console.log(priceEstimate);

Output:

{safeLowGWei: 8, fastGWei: 14, fastestGWei: 20, averageGWei: 9, speed: 0.9967071778740859, safeLowWait: 9.3, averageWait: 5.8, fastWait: 0.5, fastestWait: 0.5}