Skip to content

getsafle/vault-sol-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vault-SOL-controller

npm version Static Badge Discussions Static Badge

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

About

Solana controller for Safle Vault

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •