A Module written in javascript for managing various keyrings of Velas accounts, encrypting them, and using them.
npm install --save @getsafle/vault-velas-controller
const { KeyringController, getBalance } = require('@getsafle/vault-velas-controller');
const velasController = new KeyringController({
encryptor: {
// An optional object for defining encryption schemes:
// Defaults to Browser-native SubtleCrypto.
encrypt(password, object) {
return new Promise('encrypted!');
},
decrypt(password, encryptedString) {
return new Promise({ foo: 'bar' });
},
},
});
const keyringState = await velasController.createNewVaultAndKeychain(password);
const keyringState = await velasController.createNewVaultAndRestore(password, mnemonic);
const keyringState = await velasController.addNewAccount(keyringObject);
const privateKey = await velasController.exportAccount(address);
const signedTx = await velasController.signTransaction(velasTx, _fromAddress);
const signedMsg = await velasController.signMessage(msgParams);
const signedObj = await velasController.sign(msgParams, pvtKey, web3Obj);
const signedData = await velasController.signTypedMessage(msgParams);
rawTx: {
to, // receiver address
from, // sender address
value, // amount to send
gas, // gas Limit of transaction
gasPrice, // gasPrice
data, // data in hex to send
nonce, // transaction nonce
chainId, // chainID | 111 - TESTNET, 106 - MAINNET
}
const balance = await getBalance(address, web3);