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

one-country-sdk

v3.2.0

Published

One Country SDK

Downloads

32

Readme

one-country-sdk

Web3 library for 1.country smart contracts.

Supported contracts:

Installing

npm i one-country-sdk --save

Getting Started

1) Using Metamask provider

import detectEthereumProvider from '@metamask/detect-provider'
import { OneCountry } from 'one-country-sdk'

const provider = await detectEthereumProvider()
const oneCountry = new OneCountry({
  provider,
  contractAddress: '0x3cC3C5F98AC3FF544279919DfceBfb7aFe03A2cA'
})
const [ address ] = await window.ethereum.request({ method: 'eth_requestAccounts' })
oneCountry.setAccountAddress(address)

const price = await oneCountry.getPriceByName('all')

2) Using private key (for backend apps)

const oneCountry = new OneCountry({
  contractAddress: '0x3cC3C5F98AC3FF544279919DfceBfb7aFe03A2cA',
  privateKey: '12345'
})
const price = await oneCountry.getPriceByName('all')

3) No providers, read only

const oneCountry = new OneCountry({ contractAddress: '0x3cC3C5F98AC3FF544279919DfceBfb7aFe03A2cA' })
const price = await oneCountry.getPriceByName('all')

Configuration

Example

import { OneCountry, VanityUrl, ShortReelsVideos, DC, DCEns } from 'one-country-sdk'

const provider = await detectEthereumProvider()
const oneCountry = new OneCountry({ provider, contractAddress: '0x3cC3C5F98AC3FF544279919DfceBfb7aFe03A2cA' })
const vanityUrl = new VanityUrl({ provider, contractAddress: '0x88a1afC4134f385337Dd5F530D452079fC9E14CC' })
const shortVideos = new ShortReelsVideos({ provider, contractAddress: '0x3a6843f2AbC3CA960845108908Eae8D9d9CE058D' })
const dc = new DC({ provider, contractAddress: '0x3C84F4690De96a0428Bc6777f5aA5f5a92150Ef2' })
const dcEns = new DCEns({ provider, contractAddress: '0xeFC73fB07660464aA03A5790D011DA0512c5854f' })

Options

| Param | Default value | Description | |-----------------|---------------------------|--------------------------------------------------| | contractAddress | undefined | Contract address | | provider? | undefined | Web3 provider, optional | | rpcUrl? | https://api.harmony.one | RPC url, optional | | privateKey? | undefined | Private key, optional. Use only on backend side. |

API

OneCountry

const price = oneCountry.getPriceByName('artem')
const record = oneCountry.getRecordByName('artem')
const price = getPriceByName('artem')
const tx = await oneCountry.rent('artem', 'https://twitter.com/halfin/status/1072874040', price)
const tx = await oneCountry.updateURL('artem', 'https://twitter.com/halfin/status/321214052')
const tx = await oneCountry.setNameForRenter('artem')
const name = await oneCountry.getNameForRenter('0x726A7a5403c9C1F49f72789794358A2FfdacCA85')

Vanity URL

const price = await vanityUrl.getUrlUpdatePrice()
const tx = await vanityUrl.setNewURL('artem', 'someAlias', 'https://twitter.com', '1000000000000000000')
const price = await vanityUrl.getVanityUrlPrice('artem', 'someAlias')

Short Reels Videos

const tx = await shortReelsVideos.payForVanityURLAccessFor('0x95D02e967Dd2D2B1839347e0B84E59136b11A073', 'artem', 'someAlias', '1000000000000000000', 12345)
const tx = await shortReelsVideos.sendDonationFor('0x95D02e967Dd2D2B1839347e0B84E59136b11A073', 'artem', 'someAlias', '1000000000000000000')

DC

const isAvailable = await dc.isAvailable('artem')
const record = await dc.getRecord('artem')
const price = await dc.getPrice('artem')
const params = await dc.getParameters()
const num = await dc.getNumUrls('artem')

Testing

  1. Create new .env file in root directory, add private key
PRIVATE_KEY=12345
  1. Run test script npm run test

Harmony mainnet contracts

  oneCountry: '0x3cC3C5F98AC3FF544279919DfceBfb7aFe03A2cA',
  vanityUrlContractAddress: '0x88a1afC4134f385337Dd5F530D452079fC9E14CC',
  shortReelsVideosContractAddress: '0x3a6843f2AbC3CA960845108908Eae8D9d9CE058D',
  DC: '0x3C84F4690De96a0428Bc6777f5aA5f5a92150Ef2',