JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q35678F
  • License MIT

Wallet for SpringRole users

Package Exports

  • @springrole/springwallet

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@springrole/springwallet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SpringWallet

About

SpringWallet - A simple wallet for flexible identity management

Usage

  1. Install springwallet with npm.
npm install springwallet --save
  1. Import springwallet into your project.
const SpringWallet = require('springwallet')
  1. Generate 12 words random mnemonic
const mnemonic = SpringWallet.generateMnemonic();
  1. Store encrypted Password in Client
SpringWallet.storePassword(password);

Note: Plain text password will be the input and the encrypted password will be stored in browser's sessionStorage at key 'wallet-session'

  1. Encrypt mnemonic
SpringWallet.encryptMnemonic(mnemonic).then(function(encryptedMnemonic) {
    // Do Something like initialize wallet
    console.log("encryptedMnemonic:", encryptedMnemonic));
    SpringWallet.initializeAndUnlockWallet(encryptedMnemonic);
})

Note: mnemonic will be encrypted with the stored password in client side.

  1. Initalize a wallet and unlocks it simultaneously
SpringWallet.initializeAndUnlockWallet(encryptedMnemonic).then(function(walletAddress) {
    // Do Something
})

Note: This function will initalize a wallet instance also this will store wallet address and encryptedMnemonic in localStorage at key 'wallet-session'

  1. Fetch User's balance
SpringWallet.fetchWalletBalance().then(function(balance) {
    // Do something
    console.log("user balance:", balance);
})
  1. Generic sendTransaction function to interact with SpringChain
txParams = {
    from: "user address",
    to: "receiver address OR contract address",
    gasLimit: "gas limit",
    gasPrice: "gas price", 
    value: "value to send",
    data: "abi encoded data"
};

SpringWallet.sendTransaction(txParams).then(function(txHash) {
    // Do Something 
    console.log("transaction hash:", txHash);
})
  1. Call reserve function of Vanity contract of Springrole platform
txParams = {
    from: "user address",
    to: "VanityURL contract address",
    vanityUrl: "vanity url",
    springrole_id: "User springrole id"  
};

SpringWallet.sendVanityReserveTransaction(txParams).then(function(txHash) {
    // Do Something 
    console.log("transaction hash:", txHash);
})
  1. Call write function of Attestation contract of Springrole platform
txParams = {
    from: "user address",
    to: "Attestation contract address",
    _type_: "type of attestation",
    _data: "Data"  
}

SpringWallet.sendAttestationTransaction(txParams).then(function(txHash) {
    // Do Something
    console.log("transaction hash:", txHash);
})

Contributing

TODO