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

@swapynetwork/swapy-identity-api

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swapynetwork/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 a

  • 0.0.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

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

InputTypeDescriptionDefault value
profileDataNodesObject[]Initial profile data[]
profileDataNodes.parentLabelStringParent node label-
profileDataNodes.labelStringNode label-
profileDataNodes.dataStringLeaf content-
profileDataNodes.childrensObject[]Node childrens-
optObjectTransaction options{from: null, gas: null, gasPrice: null}
opt.fromStringWallet addressFirst account set
opt.gasIntegerGAS limit4500000
opt.gasPriceBigNumberGAS price20 gwei
OutputDescription
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

InputTypeDescriptionDefault value
identityStringIdentity's contract address-
fetchDataBooleanReturns the data valuefalse
OutputDescription
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

InputTypeDescriptionDefault value
profileNodesObject[]Insertions[]
profileNodes.parentLabelStringParent node label-
profileNodes.labelStringNode label-
profileNodes.dataStringLeaf content-
profileNodes.childrensObject[]Node childrens-
identityStringIdentity's contract address-
multiSigBooleanmulti sig identityfalse
optObjectTransaction options{from: null, gas: null, gasPrice: null}
opt.fromStringWallet addressFirst account set
opt.gasIntegerGAS limit4500000
opt.gasPriceBigNumberGAS price20 gwei
OutputDescription
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

InputTypeDescriptionDefault value
nodeLabelStringNode label-
dataStringNew content-
identityStringIdentity's contract address-
multiSigBooleanmulti sig identityfalse
optObjectTransaction options{from: null, gas: null, gasPrice: null}
opt.fromStringWallet addressFirst account set
opt.gasIntegerGAS limit4500000
opt.gasPriceBigNumberGAS price20 gwei
OutputDescription
Promise<Object, Error>A promise that resolves with the transaction object or rejects with an error
.getTokenBalance(identity)

Returns Identity's Swapy Token balance

InputTypeDescriptionDefault value
identityStringIdentity's contract address-
OutputDescription
IntegerSwapy Token balance
.getTokenBalance(identity)

Returns Identity's Swapy Token balance

InputTypeDescriptionDefault value
identityStringIdentity's contract address-
OutputDescription
IntegerSwapy Token balance
.sellIdentityData(identity, saleNodes, price)

Generates a qrCode image that contains the sale arguments

InputTypeDescriptionDefault value
identityStringIdentity's contract address-
saleNodesObject[]Profile Nodes to be sold-
saleNodes.labelStringNode label-
saleNodes.priceIntegerIndividual node price-
priceIntegerGeneral sale price-
OutputDescription
StringQRCode image url
.buyIdentityData(identity, seller, saleNodes, price, opt)

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

InputTypeDescriptionDefault value
identityStringBuyer's identity contract address-
sellerStringSeller's identity contract address-
saleNodesObject[]Profile Nodes to be sold-
saleNodes.labelStringNode label-
priceIntegerSale price-
optObjectTransaction options{from: null, gas: null, gasPrice: null}
opt.fromStringWallet addressFirst account set
opt.gasIntegerGAS limit4500000
opt.gasPriceBigNumberGAS price20 gwei
OutputDescription
ObjectData Bought

FAQs

Package last updated on 11 Apr 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