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

nas-name-service

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nas-name-service

Name service for Nebulas applications

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Universal Name Service for NAS

Name service for addresses on Nebulas blockchain platform. Unopinionated and easy to use in any scenario.

Idea

This package contains helper functions that can be used universally for each smart contract developer:

  • Enables you to store / retrieve any custom data about user that you want (displayName, rating...)
  • Share knowledge about users (by their wallet addresses) amongst all the smart contracts
  • Get all the users in the smart-contract, i.e. for autosuggestions
  • Search through wallet addresses by any property you want on smart-contract side (if you want to optimize front-end)
Motivation

I needed something like this for my dApp (fair-contracts) and I think we should have this universal, easily accessible for everyone, but still with high enough abstraction so it doesn't limit developers.

Installation

This module is distributed via [npm][npm] and should be installed as one of your project's dependencies:

npm install --save nas-name-service

or

yarn add nas-name-service

Alternatively if you are using plain JS, you should download index.js file and include it as a script.

Usage

It's super easy to use. Examples will be written in React, but you can just handle it in any framework / or vanilla in same way that you would handle any other promise.

After installing it, just include function you need via require or import, i.e.: import { getAddressInfo } from 'nas-name-service' and then use it in your code.

Table of Contents:
  • Get address Info
  • Get All Registered Addresses
  • Register new Address
  • Filter addresses by property

getAddressInfo

getAddressInfo(walletAddress)
parameters:
  • walletAddress - string - wallet address of user you want to retrieve data from
return
  • Promise, which will have Nebulas classic return call data structure:
    {
        result: {
            result: StringifiedJsonAddressObject,
            estimate_gas: string,
            execute_err: string
        }
    }
React example
getAddressInfo('n1addCChytGh672VgXRqVSzVCyXRmJUT7X7')
    .then(({ result: { result } }) => {
        this.setState({
            addressData: JSON.parse(result)
        })
    })

getAllAddresses

getAllAddresses()
parameters:

none

return
  • Promise, which will have Nebulas classic return call data structure:
    {
        result: {
            result: StringifiedArray<AddressObject>,
            estimate_gas: string,
            execute_err: string
        }
    }
React example
getAllAddresses()
    .then(({ result: { result } }) => {
        this.setState({
            suggestions: JSON.parse(result)
        })
    })

registerAddress

registerAddress(customAddressDataObject)
parameters:
  • customAddressDataObject - custom address data object. This should always contain unique displayName, so everyone can recognize this address, but other than that you can literally store everything you want in here, and then just retrieve it from getAddressInfo or getAllAddresses. Or you can get just addresses containing your special property by calling filterAddressesByProperty.
return
  • string - txhash of transaction
Example
    registerAddress(
        {
            displayName: this.state.displayName, // This should always be present
            customParam1: "Hakuna matata",
            customRating: "97.6%",
            email: "myemail@letsgo.com"
        }
    )


filterAddressesByProperty

filterAddressesByProperty(filterProperty, searchTerm)
parameters:
  • filterProperty - string - Specifies property which should be used for searching in. I.e. 'displayName'.
  • searchTerm - string - returns just entries that contain this string in the property specified in filterProperty.
return
  • Promise, which will have Nebulas classic return call data structure:
    {
        result: {
            result: StringifiedArray<AddressObject>, // Addresses that satisfy search query and contain specified property
            estimate_gas: string,
            execute_err: string
        }
    }
Example
filterAddressesByProperty("displayName", "Ol")
    .then(({ result: { result } }) => {
        this.setState({
            suggestions: JSON.parse(result) // returns just suggestion containing "Ol".
        })
    })

FAQs

Package last updated on 09 Jun 2018

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