@getsafle/vault-stacks-controller
v1.0.5
Published
Stacks chain controller for Safle Vault
Downloads
22
Keywords
Readme
vault-stacks-controller
Install
npm install --save @getsafle/vault-stacks-controller
Initialize the Stacks Controller class
const { KeyringController, getBalance } = require('@getsafle/vault-stacks-controller');
const stacksController = new KeyringController({
// 12 words mnemonic to create wallet
mnemonic: string,
// network - type of network [TESTNET|MAINNET]
// default is MAINNET even if no network is passed
network: string (TESTNET | MAINNET)
});
Methods
Generate Wallet with 1 account
await stacksController.generateWallet();
add new account
const keyringState = await stacksController.addAccount();
Export the private key of an address present in the keyring
const privateKey = await stacksController.exportPrivateKey(address);
Get all accounts in the keyring
const privateKey = await stacksController.getAccounts();
Sign a transaction
const signedTx = await stacksController.signTransaction(stacksTx);
STX transfer transaction:
stacksTx: {from, to, amount, transactionType, memo: (optional)}
Token transfer transaction:
stacksTx: {
from,
to,
amount,
transactionType,
contractDetails: { contractAddress, contractName, assetName },
memo: (optional)
}
transactionType = 'token_transfer' || 'contract_call'
Sign a message
const signedMsg = await stacksController.signMessage(msgString, address);
Get fees
const fees = await stacksController.getFees(rawTransaction);
Get balance
const balance = await getBalance(address, network); // if network !== TESTNET then it will fetch mainnet balance