1.2.0 • Published 5 years ago

eth-registry v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Eth Registry

Greenkeeper badge Build
Status code style:
prettier Ethereum Dapp
Badge

A Node.js module to easily retrieve address metadata from Eth Registry's Ethereum contract.

https://ethregistry.org

Setup

Usage:

yarn add theregistry

API

Functions

get(_address) ⇒ string | string

Retrieve metadata for this address

Kind: global function
Returns: string - Address Metadata object with received metadata or null when no metadata availablestring - Name Metadata object with received metadata or null when no metadata available

ParamType
_addressstring

Example

import Registry from "eth-registry";
import Web3 from "web3";

const provider = new Web3.providers.HttpProvider(
  `https://mainnet.infura.io/`,
);

const registry = new Registry(provider);
registry
  .get(ensaddress)
  .then(r => {
      console.log(r.data);
  })
  .catch(e => console.error(e));

storeMetadata(_address, _name, _data, _callback) ⇒ string

Stores address metadata on Eth Registry

Kind: global function
Returns: string - TX Hash of the submitted file

ParamTypeDescription
_addressstringAddress for which you are submitting data
_namestringName of the address
_datastringMetadata object
_callbackfunctionCallback for when the transaction receipt is returned

storeJsonFileIPFS(Blob) ⇒ string

Reads content of a JSON file and stores it on IPFS

Kind: global function
Returns: string - IPFS Hash of stored file

ParamTypeDescription
Blobblobaccepted by Filereader

storeDataFileIPFS(Blob) ⇒ string

Reads content of a Plaintext file and stores it on IPFS

Kind: global function
Returns: string - IPFS Hash of stored file

ParamTypeDescription
Blobblobaccepted by Filereader

convertBlobToBase64(Blob) ⇒ string

Converts an image blob to a base64 string

Kind: global function
Returns: string - base64 encoded image file

ParamTypeDescription
Blobblobaccepted by Filereader

lookUp(IPFS) ⇒ string

Reads content of a JSON file and stores it on IPFS

Kind: global function
Returns: string - JSON contents returned from IPFS

ParamTypeDescription
IPFSstringaddress to look up

price(unit) ⇒ number

Retrieve the current price for submitting data to Eth Registry

Kind: global function
Returns: number - Current price

ParamTypeDefaultDescription
unitstring"ether"Unit to convert the price to (defaults to 'ether')

getHistory() ⇒ string

Retrieve the last 10 submissions to Eth Registry

Kind: global function
Returns: string - the last 10 submissions to Eth Registry

Development

  • npm run clean - Remove lib/ directory
  • npm test - Run tests with linting and coverage results.
  • npm test:only - Run tests without linting or coverage.
  • npm test:watch - You can even re-run tests on file changes!
  • npm test:prod - Run tests with minified code.
  • npm run test:examples - Test written examples on pure JS for better understanding module usage.
  • npm run lint - Run ESlint with airbnb-config
  • npm run cover - Get coverage report for your code.
  • npm run build - Babel will transpile ES6 => ES5 and minify the code.
  • npm run prepublish - Hook for npm. Do all the checks before publishing your module.

License

MIT © Alexander Mangel