juicewallet

1.2.0 • Public • Published

JuicEchain Wallet SDK

JuicEchain The management of digital assets will be an essential part of new business models and close connected to their success. Our JuicEchain solution is the tool to enable and guarantee exactly that. It’s the easiest available access to blockchain technology without worrying about technical and infrastructure (node-network) requirements, accessible as any other cloud service. Learn more here.

NodeJS SDK for managing a Wallet from JuicEchain Blockchain Network. Supported are standard wallet operations like fetching balance, assets and transferring.

Prerequisite

  • Node The Node name you like to connect
  • ApiKey API key of user

Access to functions of the JuicEchain Wallet API is based on Authorization and Authentication

Authorization

Authorization is general API access based on the API-Key in the header parameter authorization. Authorization is required for all API requests. If the parameter is missing, or your user invalid / deactivated, access is denied.

Authentication

Authentication is an additional parameter authentication in the request body, identifying the wallet the request is based on. This is realized by a so called "BitCoin Message", which is signed with the wallet owners private key. Authentication can be generated by calling "getAuthentication()" method on a wallet reference, but the SDK has all these functions build-in so and is taking care of it. Authentication tokens, are short-lived tokens, so we can ensure they are only used by you!

Most Blockchains transactions are signed with the private-key of the sender, to confirm the ownership of the wallet.

Good to Know

Wallet

Wallet is a unique address in JuicEchain which allows its owner to manage and collect digital Assets. It is based on asymmetric encryption with public (wallet address) and private keys (made for securing and signing every transaction).

Digital Asset

Digital Asset is a unique digital representation of Tickets, Vouchers, Coupons, Contracts or Identities in JuicEchain network. Users can issue digital assets in amount they need with all necessary parameters and transfer them unlimited number of times. Every digital Asset has these properties:

  • Name - unique name in whole network (only 1 digital Asset can be defined with specific name)
  • Amount - total issued amount
  • Title - name of digital Asset displayed in all apps using JuicEchain
  • Description - long specific description
  • Inception date - time from which digital asset is valid
  • Expiration date - time until digital asset is valid
  • Media - upload picture or video representing digital Asset
  • Options - additional options like allowing transfer, transferring only inside home Node or returning digital Asset to owner

Digital Asset Classifications

There are 3 different classifications of digital Assets

  1. Multi Asset (Fungible Asset)

    • Multi Assets are the default classification and are specified by the initial amount issued. Each multi asset has the same properties and can't be distinguish between each other.
  2. Master Asset

    • Master Assets are the template for Non-fungible (NFT) assets or child assets. All properties specified on the master asset are mirrored to each child, if not overwritten by the child.
    • Only the owner of the Master asset is allowed to issue NFT's of this class.
    • The quantity of master assets is limited to one only, but declares the amount of child assets allowed to be issued.
  3. Asset (NFA - Non Fungible Asset)

    • None fungible asset are a copy of its master, but can overwrite or contain additional / different properties.
    • E.g. Ticket which has a unique seat allocation in a Theatre, Stadium, Bus or even Hotel room door key.

Digital Asset Types

JuicEchain defines 5 general types of digital Assets, which can be applied to the respective use-case.

Type Description
admission Ticket, Entry pass
voucher Redeemable transaction type which is worth a certain monetary value
coupon Redeemed for a financial discount
contract Agreement between multiple parties
identity Piece of identification or ID

Asset Name

Asset names are unique in the whole network and limited to 32 character including the nodes prefix. Default separation character is : and only required once after the nodes name:

Example asset name, issued on the node "Demo"

demo:exampleassetname

A special case are Master and Child assets. Master assets need to end with # Hashtag.

// Master Asset Name
demo:examplemaster#

// Child assets can occupy all left character space after the hashtag
demo:examplemaster#1

Regex for Asset name /^[a-z0-9#]+([\:]{1}[a-z0-9#]+)*$/g;

Blocktime

JuicEchain has an internal block-time of 10 seconds. After a successful transfer, the asset should appear in the receivers wallet, latest after 10 seconds! However, its possible with the parameter "minconf" to get instant results even of transaction which are yet not minded e.g confirmed by any node.

Coding Examples

Connect to Node

Create a new Node reference by calling "getNode()" from JuicEchain.

const demo:Node = await JuicEchain.connect("demo", "*-api-key-*");

Create your first Wallet

Wallets are connected to their origin Node. You can call "createWallet()" method on the Node reference to receive a new wallet. The wallet is connected to your API user.

 const wallet:Wallet = await demoNode.createWallet();

Fetch wallet balance

The balance (overview of assets owned and amount) can be fetched directly from the Wallet reference.

balance:Array<Balance> = wallet.balance();

Possible result as JSON

[{
  asset: "demo:myasset",
  quantity: 2
}]

Transfer asset

Call `wallet.transfer()" to transfer the given asset with amount to the receivers address.

 successTransfer:boolean = wallet.transfer(*some-wallet-address*, "demo:myasset", 2, "");

Readme

Keywords

Package Sidebar

Install

npm i juicewallet

Weekly Downloads

22

Version

1.2.0

License

MIT

Unpacked Size

30.2 kB

Total Files

20

Last publish

Collaborators

  • nemicko