2.3.1 • Published 5 years ago

ncent-sandbox-sdk v2.3.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

ncentSDK

Overview

ncentSDK is a Javascript library for communicating with the nCent API. It is used for building nCent applications either on Node.js or in the browser, as well as for accessing base-level features on the API.

It provides:

  • a networking layer for endpoints on the back-end API.
  • eventual facilities for building and signing transactions, for communicating with the backend API, and for submitting transactions or querying network history.

Install

To use as a module in a Node.js project

  1. Install it using npm:

    npm i ncent-sandbox-sdk
  2. require/import it:

    const nCentSDK = require('ncent-sandbox-sdk');

To develop and test the SDK:

  1. Clone the repo:

    git clone https://github.com/ncent/ncent-SDK.js
  2. Install dependencies inside our ncentSDK folder:

    cd ncent-SDK.js
    npm install

Documentation

Constructor

new ncentSDK(ip_address)

Description:

Create an instance of the nCent SDK class, specifying the IP of the Sandbox instance with which you will communicate.

Parameters:

NameTypeDescription
ip_addressStringNetwork on which to connect to the API. This defaults to the IP of the Sandbox hosted on AWS. If you are running the sandbox locally, pass http://localhost:8010/api

Methods


createWalletAddress

createWalletAddress()

Description:

Creates a KeyPair object.

Parameters:

None



getWallets

getWallets()

Description:

Retrieves all wallets

Parameters:

None



getWallet

getWallet(publicKey)

Description:

Retrieves a specific wallet

Parameters:

NameTypeDescription
publicKeyStringValid public key associated with a wallet


getWalletBalance

getWalletBalance(publicKey, tokenTypeUuid)

Description:

Retrieves a specific wallet's balance of a stamped TokenType

Parameters:

NameTypeDescription
publicKeyStringValid public key associated with a wallet
tokenTypeUuidStringUUID of a stamped TokenType


stampToken

stampToken(publicKey, tokenName, totalTokens, expiryDate)

Description:

Initiates a new token type and creates totalTokens amount of these tokens. Note: For development, one can stamp tokens out of nothing, and thus stampTokens can be used to instantiate new tokens for free. In the production version of our SDK, only ncnt will be allowed to be stamped into new tokens.

Parameters:

NameTypeDescription
publicKeyStringpublic key of wallet stamping token
tokenNameStringName of token the user wants to create.
numTokensintNumber of tokens to create.
expiryDataintDate of expiration for token.


getTokenTypes

getTokenTypes()

Description:

returns all TokenTypes

Parameters:

none



getTokenTypeData

getTokenTypeData(tokenTypeUuid)

Description:

returns data and transactions of a tokenType

Parameters:

NameTypeDescription
tokenTypeUuidStringUUID of a stamped TokenType


getTransactions

getTransactions

Description:

returns all Transactions

Parameters:

none



createChallenge

createChallenge(senderKeyPair, tokenTypeUUid, amount)

Description:

Allows a TokenType sponsor to create a challenge. This challenge can be transferred to other wallets as a transaction

Parameters:

NameTypeDescription
senderKeyPairstellarKeyPairSender wallet with secretKey and public key
tokenTypeUuidStringUUID of owned TokenType
amountIntegerdesignated count of tokens to issue as part of challenge


shareChallenge

shareChallenge(senderKeyPair, transactionUuid, toAddress)

Description:

Allows the owner of a challenge (transaction) to transfer it

Parameters:

NameTypeDescription
senderKeyPairstellarKeyPairSender wallet with secretKey and public key
transactionUuidStringUUID of owned transaction (challenge)
toAddressStringpublic key to transfer ownership of challenge to


redeemChallenge

redeemChallenge(ownerKeyPair, transactionUuid)

Description:

Allows the owner of a TokenType to trigger redemption. This will create a transaction between the current challenge owner and Token Graveyard.

Parameters:

NameTypeDescription
ownerKeyPairstellarKeyPairOwner wallet with secretKey and public key
transactionUuidStringUUID of owned transaction (challenge)


retrieveProvenanceChain

retrieveProvenanceChain(transactionUuid)

Description:

Gets the parents of a transaction recursively

Parameters:

NameTypeDescription
transactionUuidStringUUID of a transaction (challenge)


retrieveProvenanceChainFIFO

retrieveProvenanceChainFIFO(tokenTypeUUid, publicKey)

Description:

Gets the provenance of the oldest received transaction (challenge) of a specific TokenType that has not been shared.

Parameters:

NameTypeDescription
publicKeyStringvalid wallet public key
tokenTypeUuidStringUUID of a stamped TokenType


Usage

Check the examples folder for usage examples.

Contributing

For information on how to contribute, please email kk@ncnt.io, mb@ncnt.io, or af@ncnt.io

License

SDK is licensed under ...


2.3.1

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.3

5 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.8.0

6 years ago

1.7.5

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.2.4

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago