npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@getsafle/vault-tezos-controller

v1.0.2

Published

`npm install --save @getsafle/vault-tezos-controller`

Downloads

6

Readme

vault-tezos-controller

Install

npm install --save @getsafle/vault-tezos-controller

Initialize the Tezos Controller class

const { KeyringController, getBalance } = require('@getsafle/vault-tezos-controller');

const tezosController = new KeyringController({
    // 12 words mnemonic to create wallet
    mnemonic: string,
    // network - type of network [TEZOS_TESTNET_GHOSTNET | TEZOS_TESTNET_HANGZHOU | TEZOS_TESTNET_GRANADANET | CONSEIL_TESTNET_HANGZHOU | CONSEIL_TESTNET_GRANADANET | TEZOS_MAINNET | CONSEIL_MAINNET]
    // default is TEZOS_MAINNET even if no network is passed
    network: string (TEZOS_TESTNET_GHOSTNET | TEZOS_TESTNET_HANGZHOU | TEZOS_TESTNET_GRANADANET | CONSEIL_TESTNET_HANGZHOU | CONSEIL_TESTNET_GRANADANET | TEZOS_MAINNET | CONSEIL_MAINNET)
});

Methods

Generate Keyring with 1 account or add new account

const keyringState = await tezosController.addAccount();

Export the private key of an address present in the keyring

const privateKey = await tezosController.exportPrivateKey(address);

Get all accounts in the keyring

const privateKey = await tezosController.getAccounts();

Sign a transaction

const signedTx = await tezosController.signTransaction(tezosTx: TransactionObj);
TransactionObj
  1. Activate account (only Fundraiser accounts): Any Fundraiser wallet needs to be activated before it can accept funds.We will create account from mnemonic so this function is not required.The transaction object is of the following type:
TransactionObj: {
    data: {},
    txnType: ACTIVATE_ACCOUNT, // type constant
    from //sender address
}
  1. Reveal account: Any tezos wallet needs to be revealed, i.e. published on the network to perform transactions.The account will need to pay fee for the transaction and hence there should be some value in it.The transaction object is of the following type:
TransactionObj: {
    data: {},
    txnType: REVEAL_ACCOUNT, // type constant
    from //sender address
}
  1. TEZ transfer: Trasaction to transfer XTZ from one wallet/address to another.The transaction object is of the following type:
TransactionObj: {
    data: {
        to, // destination address
        amount, // amount in µtz (micro-tez)
    },
    txnType: NATIVE_TRANSFER, // type constant
    from //sender address
}
  1. Delegate: Transaction to delegate an account for voting process.The transaction object is of the following type:
TransactionObj: {
    data: {
        delegate, // delegate address (optional)
    },
    txnType: DELEGATE // type constant
    from //sender address
}
  1. Contract Deployment: Transaction to deploy a smart contract.The transaction object is of the following type:
TransactionObj: {
    data: {
        amount, // amount to send to contract (if payable)
        delegate, // delegate contract
        fee, // contract fee
        storageLimit, // storage limit
        gasLimit, // gas limit
        code, // contract michelson code
        storage // storage variables
    },
    txnType: DEPLOY_CONTRACT_TRANSACTION, // type constant
    from //sender address
}
  1. Invoke Contract: Transaction to call functions of smart contract.The transaction object is of the following type:
TransactionObj: {
    data: {
        contractAddress, // address of contract to call
        amount, // amount (if payable)
        fee, // transaction fee
        storageLimit, // storage limit
        gasLimit, // gas limit
        entrypoint, // function to call
        parameters, // function params / storage params value
    },
   txnType: CONTRACT_TRANSACTION, // type constant
   from //sender address
}

parameters:

name: transaction,
type: TransactionObj, // refer to the above 6 trancationObj types.
Return Object:
signedTransactionObject: {
  results: {
    contents: [Array],
    signature : string // 'edsigu1yWMor3YgXpFtHm7PEd86mCT8ruavGsB6AYnqUrgb9ZgcfRLBbw5bpq6CsiCUwNWsBTKQf6jpPASSZQTD46Wuk7PKmFyg'
  },
  signedOperations: {
    bytes: Buffer // <Buffer 081b31e64fd4e006fe34d71a69fbb101c4ce6bdc2989c87922662eec27b8566f6c0011ad4e6efaf8690155cdf8b5132b0d60...103morebytes>,
    signature: string //'edsigu1yWMor3YgXpFtHm7PEd86mCT8ruavGsB6AYnqUrgb9ZgcfRLBbw5bpq6CsiCUwNWsBTKQf6jpPASSZQTD46Wuk7PKmFyg'
  }
}

returns: {signedTransaction: signedTransactionObject} signed raw transaction

Sign a message

const signedMsg = await tezosController.signMessage(msgString, address);

Get fees

const fees = await tezosController.getFee(address);

Get balance

const balance = await getBalance(address, network); // if network !== TESTNET || then it will fetch mainnet balance