Installation & Initialisation
NPM Link : https://www.npmjs.com/package/@getsafle/safle-vault
Installation
Package import & initialisation:
vault
(optional) - If the user already has a vault string generated, then it can be passed as the first parameter. If the vault string is not passed, then the vault has to be generated using thegenerateVault()
function.customEncryptor
(optional) - If the user wants to use their own custom encryption/decryption function.platform
(optional) - The platform on which the vault sdk is integrated with. This data will be helpful for logging purpose.storage
(optional) - The storage mechanism for vault. Can be an array of strings incase there are multiple storage mechanisms.
💡 If the vault is not yet generated, then pass the vault parameter as null.
Functions :
Generate Mnemonic This method is used to generate the 12 word seed phrase for the vault.
Returns a 12 word seed phrase
entropy
(optional) - The entropy used to generate the 12 word seed phrase. (Uses crypto.randomBytes under the hood). Defaults to 128-bits of entropy.
Generate Vault This method is used to generate a vault using a specific mnemonic and encrypted with the user's password and PIN.
Returns the encrypted vault string
encryptionKey
- 64 bytes Uint8Array used to encrypt the vault.pin
- The pin to access the vault's private functions.mnemonic
- The mnemonic to generate the vault from.
Recover Vault
This method is used to recover the vault using the mnemonic phrase. The new vault will be re-encrypted using the pin and encryption key.
Returns the encrypted vault string
mnemonic
- The mnemonic of the vault to be recovered.encryptionKey
- The encryption key used to encrypt/decrypt the vault.pin
- The pin to access the vault's private functions.unmarshalApiKey
- API Key of unmarshal api.recoveryMechanism
- logs/transactions. Defaults to transactions.unmarshalApiKey
required if recovery mechanism is transactionslogs
: Array of vault logs objects
Get Supported chains
This method is used to fetch a list of chains supported by vault SDK
Returns a list of all chains supported by Safle Vault
Change network: Change the active network
chain
: Name of chain from the supported chains
Add Account This method adds a new account to the keyring.
Returns the encrypted vault string and newly generated wallet address
encryptionKey
- The encryption key used to decrypt the vault.pin
- The pin to access the vault's private functions.
Get Accounts This method is used to get the list of all the accounts in the vault.
Returns an array of accounts
encryptionKey
- 64 bytes Uint8Array used to encrypt the vault.
Delete Account This method is used to delete an account from the Keyring.
Returns the new vault string with an account deleted
encryptionKey
- The encryption key used to decrypt the vault.pin
- The pin to access the vault's private functions.address
- The public address of the account to be deleted
Import Account This method is used to import an account with a private key
Returns the new vault string with an account imported
encryptionKey
- The encryption key used to decrypt the vault.pin
- The pin to access the vault's private functions.privateKey
- The private key of the account to be imported
Export Mnemonic This method is used to export the 12 word seed phrase used to generate the account keypairs in the vault.
Returns the 12 word seed phrase with which the vault is generated
pin
- The pin to access the vault's private functions.
Export Private Key This method is used to export the private key of a specific wallet in the vault
Returns the private key for the requested wallet
pin
- The pin to access the vault's private functions.address
- The public address of the account to be deleted
Update Wallet Label: This method is used to update the wallet label.
Returns the updated vault string
address
- The address for which the label is to be updated.encryptionKey
- The encryption key used to encrypt/decrypt the vault.newLabel
- The new label to be added.
Change Pin: This method is used to change the pin of the vault.
currentPin
- The existing vault pin.newPin
- The new vault pin.encryptionKey
- The encryption key used to encrypt/decrypt the vault.
Get Logs: This method retrieves all the logs of all the vault changes.
Returns array of vault logs objects
Get Fees: This method returns an object containing gas limit, gas price wrt the speed of transaction confirmation
rawTx
- The raw transaction object.rpcUrl
- The RPC URL for the chain.
Sign Message This method is used to sign a message and return the signed message string
Returns the signed message string
address
- The address for which the message is to be signed.data
- The message to be signedpin
- The pin to access the vault's private functions.
Sign Transaction This method is used to sign a raw transaction and return the signed transaction string
Returns the signed transaction string
chain
- The chain for which the transaction is to be signed.rawTx
- The raw transaction object to be signedpin
- The pin to access the vault's private functions.
Last updated