0.1.3 • Published 5 years ago
springwallet v0.1.3
SpringWallet
About
SpringWallet - A simple wallet for flexible identity management
Usage
- Install
springwallet
withnpm
.
npm install springwallet --save
- Import springwallet into your project.
const SpringWallet = require('springwallet')
- Generate 12 words random mnemonic
const mnemonic = SpringWallet.generateMnemonic();
- 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'
- 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.
- 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'
- Fetch User's balance
SpringWallet.fetchWalletBalance().then(function(balance) {
// Do something
console.log("user balance:", balance);
})
- 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);
})
- 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);
})
- 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