Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

one-country-sdk

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

one-country-sdk

One Country SDK

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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
ParamDefault valueDescription
contractAddressundefinedContract address
provider?undefinedWeb3 provider, optional
rpcUrl?https://api.harmony.oneRPC url, optional
privateKey?undefinedPrivate 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',

Keywords

FAQs

Package last updated on 10 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc