@getsafle/vault-sol-controller
v1.0.1
Published
Solana chain controller for Safle Vault
Downloads
33
Keywords
Readme
vault-SOL-controller
Install
npm install --save @getsafle/vault-sol-controller
Initialize the solana Controller class
const { KeyringController, getBalance } = require('@getsafle/vault-sol-controller');
const solController = 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
add new account
const keyringState = await solController.addAccount();
Export the private key of an address present in the keyring
const privateKey = await solController.exportPrivateKey(address);
Get all accounts in the keyring
const privateKey = await solController.getAccounts();
Sign a transaction
const signedTx = await solController.signTransaction(solTx);
STX transfer transaction:
solTx: {from, to, amount, txnType}
Token transfer transaction:
solTx: {from, to, amount, txnType, token}
transactionType = 'NATIVE_TRANSFER' || 'TOKEN_TRANSFER'
Sign a message
const signedMsg = await solController.signMessage(msgString, address);
Get fees
const fees = await solController.getFees(rawTransaction);
Get balance
const balance = await getBalance(address, network); // if network !== TESTNET then it will fetch mainnet balance