0.0.16 • Published 6 years ago

@swapynetwork/swapy-identity-api v0.0.16

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
6 years ago

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
0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago