@getsafle/vault-stacks-controller

1.0.5 • Public • Published

vault-stacks-controller

npm version Static Badge Discussions Static Badge

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

Readme

Keywords

none

Package Sidebar

Install

npm i @getsafle/vault-stacks-controller

Weekly Downloads

73

Version

1.0.5

License

MIT

Unpacked Size

35.3 kB

Total Files

20

Last publish

Collaborators

  • subhanshugupta
  • apoorv31
  • shubham.3008
  • sidth