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

@swapynetwork/swapy-identity-api

v0.0.16

Published

Swapy Identity API aims to ease the interaction with Swapy financial identities. The current implementation was designed to be used on browsers and it provides methods to: * Create personal and multi sig identities; * Manage identity's data on IPFS a

Downloads

25

Readme

Swapy Identity API

Swapy Identity API aims to ease the interaction with Swapy financial identities. The current implementation was designed to be used on browsers and it provides methods to:

  • Create personal and multi sig identities;
  • Manage identity's data on IPFS and Ethereum;
  • Forward transactions through a personal identity;
  • Create, sign and execute transactions on multi sig identities;
  • Decentralized attestation of identitiy's credentials on IPFS with QRCode for third-parties;

Check out our smart contracts and Wiki for more details around Swapy Identity Protocol.

Install

The API is available on NPM. So, install it

npm install @swapynetwork/swapy-identity-api

Usage Guide

Init the API with a first account, Ethereum http provider and network parameters as well.

import { Api } from '@swapynetwork/swapy-identity-api'
const api = new Api('<0xPrivateKey>','<ethereumHttpProvider')

Doc

  • Api
    • new Api(privateKey,httpProvider,_networkName)
    • .createPersonalIdentity(profileDataNodes, opt) : Promise.<Object, Error>
    • .getProfileData(identity, fetchData) : Promise.<Object, Error>
    • .insertProfileData(profileNodes, identity, multiSig, opt) : Promise.<Object, Error>
    • .updateProfileData(nodeLabel, data, identity, multiSig, opt) : Promise.<Object, Error>
    • .getTokenBalance(identity) : Integer
    • .sellIdentityData(identity, saleNodes, price) : String
    • .buyIdentityData(identity, seller, saleNodes, price, opt) : Object

.createPersonalIdentity(profileDataNodes, opt)

Instantiates a new personal identity

| Input | Type | Description | Default value | |------------------------------|-----------|----------------------|-----------------------------------------| | profileDataNodes | Object[] | Initial profile data | [] | | profileDataNodes.parentLabel | String | Parent node label | - | | profileDataNodes.label | String | Node label | - | | profileDataNodes.data | String | Leaf content | - | | profileDataNodes.childrens | Object[] | Node childrens | - | | opt | Object | Transaction options | {from: null, gas: null, gasPrice: null} | | opt.from | String | Wallet address | First account set | | opt.gas | Integer | GAS limit | 4500000 | | opt.gasPrice | BigNumber | GAS price | 20 gwei |

| Output | Description | |-------------------------|-------------------------------------------------------------------------------| | Promise<Object, Error> | A promise that resolves with the transaction object or rejects with an error |

.getProfileData(identity, fetchData)

Returns the profile data of an identity

| Input | Type | Description | Default value | |-----------|-----------|-----------------------------|----------------| | identity | String | Identity's contract address | - | | fetchData | Boolean | Returns the data value | false |

| Output | Description | |-------------------------|--------------------------------------------------------------------------| | Promise<Object, Error> | A promise that resolves with the profile object or rejects with an error |

.insertProfileData(profileNodes, identity, multiSig, opt)

Inserts nodes on the profile tree

| Input | Type | Description | Default value | |--------------------------|-----------|-----------------------------|-----------------------------------------| | profileNodes | Object[] | Insertions | [] | | profileNodes.parentLabel | String | Parent node label | - | | profileNodes.label | String | Node label | - | | profileNodes.data | String | Leaf content | - | | profileNodes.childrens | Object[] | Node childrens | - | | identity | String | Identity's contract address | - | | multiSig | Boolean | multi sig identity | false | | opt | Object | Transaction options | {from: null, gas: null, gasPrice: null} | | opt.from | String | Wallet address | First account set | | opt.gas | Integer | GAS limit | 4500000 | | opt.gasPrice | BigNumber | GAS price | 20 gwei |

| Output | Description | |-------------------------|------------------------------------------------------------------------------| | Promise<Object, Error> | A promise that resolves with the transaction object or rejects with an error |

.updateProfileData(profileNodes, identity, multiSig, opt)

Inserts nodes on the profile tree

| Input | Type | Description | Default value | |--------------------------|-----------|-----------------------------|-----------------------------------------| | nodeLabel | String | Node label | - | | data | String | New content | - | | identity | String | Identity's contract address | - | | multiSig | Boolean | multi sig identity | false | | opt | Object | Transaction options | {from: null, gas: null, gasPrice: null} | | opt.from | String | Wallet address | First account set | | opt.gas | Integer | GAS limit | 4500000 | | opt.gasPrice | BigNumber | GAS price | 20 gwei |

| Output | Description | |-------------------------|------------------------------------------------------------------------------| | Promise<Object, Error> | A promise that resolves with the transaction object or rejects with an error |

.getTokenBalance(identity)

Returns Identity's Swapy Token balance

| Input | Type | Description | Default value | |-----------|-----------|-----------------------------|----------------| | identity | String | Identity's contract address | - |

| Output | Description | |----------|----------------------| | Integer | Swapy Token balance |

.getTokenBalance(identity)

Returns Identity's Swapy Token balance

| Input | Type | Description | Default value | |-----------|-----------|-----------------------------|----------------| | identity | String | Identity's contract address | - |

| Output | Description | |----------|----------------------| | Integer | Swapy Token balance |

.sellIdentityData(identity, saleNodes, price)

Generates a qrCode image that contains the sale arguments

| Input | Type | Description | Default value | |-----------------|-----------|-----------------------------|----------------| | identity | String | Identity's contract address | - | | saleNodes | Object[] | Profile Nodes to be sold | - | | saleNodes.label | String | Node label | - | | saleNodes.price | Integer | Individual node price | - | | price | Integer | General sale price | - |

| Output | Description | |----------|-------------------| | String | QRCode image url |

.buyIdentityData(identity, seller, saleNodes, price, opt)

Transfer tokens to seller's identity and retrieve the data bought

| Input | Type | Description | Default value | |-----------------|-----------|------------------------------------|-----------------------------------------| | identity | String | Buyer's identity contract address | - | | seller | String | Seller's identity contract address | - | | saleNodes | Object[] | Profile Nodes to be sold | - | | saleNodes.label | String | Node label | - | | price | Integer | Sale price | - | | opt | Object | Transaction options | {from: null, gas: null, gasPrice: null} | | opt.from | String | Wallet address | First account set | | opt.gas | Integer | GAS limit | 4500000 | | opt.gasPrice | BigNumber | GAS price | 20 gwei |

| Output | Description | |----------|-------------------| | Object | Data Bought |