0.0.4 • Published 5 years ago

springrolewallet v0.0.4

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

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