Class Sotez

Main Sotez Library

Example

import { Sotez } from 'sotez';
const tezos = new Sotez('https://127.0.0.1:8732', { defaultFee: 1500, useMutez: false, useLimitEstimator: true });
await tezos.importKey('edskRv6ZnkLQMVustbYHFPNsABu1Js6pEEWyMUFJQTqEZjVCU2WHh8ckcc7YA4uBzPiJjZCsv3pC1NDdV99AnyLzPjSip4uC3y');
const result = await tezos.transfer({
to: 'tz1RvhdZ5pcjD19vCCK9PgZpnmErTba3dsBs',
amount: 10,
});

Hierarchy

Constructors

Properties

_chain: string
_debugMode: boolean
_defaultFee: number
_localForge: boolean
_provider: string
_useLimitEstimator: boolean
_useMutez: boolean
_validateLocalForge: boolean
key: Key

Accessors

  • get chain(): string
  • Returns string

  • set chain(value: string): void
  • Parameters

    • value: string

    Returns void

  • get debugMode(): boolean
  • Returns boolean

  • set debugMode(t: boolean): void
  • Parameters

    • t: boolean

    Returns void

  • get defaultFee(): number
  • Returns number

  • set defaultFee(fee: number): void
  • Parameters

    • fee: number

    Returns void

  • get localForge(): boolean
  • Returns boolean

  • set localForge(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get provider(): string
  • Returns string

  • set provider(provider: string): void
  • Parameters

    • provider: string

    Returns void

  • get useLimitEstimator(): boolean
  • Returns boolean

  • set useLimitEstimator(t: boolean): void
  • Parameters

    • t: boolean

    Returns void

  • get useMutez(): boolean
  • Returns boolean

  • set useMutez(t: boolean): void
  • Parameters

    • t: boolean

    Returns void

  • get validateLocalForge(): boolean
  • Returns boolean

  • set validateLocalForge(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

Methods

  • Description

    Activate an account

    Returns

    Object containing the injected operation hash

    Example

    tezos.activate(pkh, secret)
    .then((activateOperation) => console.log(activateOperation));

    Parameters

    • pkh: string

      The public key hash of the account

    • secret: string

      The secret to activate the account

    Returns Promise<any>

  • Description

    Check for the inclusion of an operation in new blocks

    Returns

    The hash of the block in which the operation was included

    Example

    tezos.awaitOperation('ooYf5iK6EdTx3XfBusgDqS6znACTq5469D1zQSDFNrs5KdTuUGi')
    .then((hash) => console.log(hash));

    Parameters

    • hash: string

      The operation hash to check

    • Optional interval: number = 5

      The interval to check new blocks (in seconds)

    • Optional timeout: number = 180

      The time before the operation times out (in seconds)

    Returns Promise<string>

  • Description

    Get the baker information for an address

    Returns

    The information of the delegate address

    Example

    tezos.getBaker('tz1fXdNLZ4jrkjtgJWMcfeNpFDK9mbCBsaV4')
    .then(({
    balance,
    frozen_balance,
    frozen_balance_by_cycle,
    staking_balance,
    delegated_contracts,
    delegated_balance,
    deactivated,
    grace_period,
    }) => console.log(
    balance,
    frozen_balance,
    frozen_balance_by_cycle,
    staking_balance,
    delegated_contracts,
    delegated_balance,
    deactivated,
    grace_period,
    ));

    Parameters

    • address: string

      The contract for which to retrieve the baker information

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<Baker>

  • Description

    Get the balance for a contract

    Returns

    The balance of the contract

    Example

    tezos.getBalance('tz1fXdNLZ4jrkjtgJWMcfeNpFDK9mbCBsaV4')
    .then(balance => console.log(balance));

    Parameters

    • address: string

      The contract for which to retrieve the balance

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<string>

  • Description

    Ballots casted so far during a voting period

    Returns

    Ballots casted so far during a voting period

    Example

    tezos.getBallotList().then(ballotList => console.log(ballotList));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<any[]>

  • Description

    Sum of ballots casted so far during a voting period

    Returns

    Sum of ballots casted so far during a voting period

    Example

    tezos.getBallots().then(({ yay, nay, pass }) => console.log(yay, nay, pass));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<{ nay: number; pass: number; yay: number }>

  • Description

    Get the current head block of the chain

    Returns

    The current head block

    Example

    tezos.getHead().then(head => console.log(head));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to retrieve

    Returns Promise<Block>

  • Description

    Get the current head block hash of the chain

    Returns

    The block's hash, its unique identifier

    Example

    tezos.getHeadHash().then(headHash => console.log(headHash))
    

    Parameters

    • Optional block: string | number = 'head'

      The block to retrieve the hash from

    Returns Promise<string>

  • Description

    Get the header of the current head

    Returns

    The whole block header

    Example

    tezos.getHeader().then(header => console.log(header));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to retrieve the header from

    Returns Promise<Header>

  • Description

    Get the metadata of the current head

    Returns

    The head block metadata

    Example

    tezos.getBlockMetadata().then(metadata => console.log(metadata));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to retrieve the block metadata from

    Returns Promise<Header>

  • Description

    Get the counter for an contract

    Returns

    The counter of a contract, if any

    Example

    tezos.getCounter('tz1fXdNLZ4jrkjtgJWMcfeNpFDK9mbCBsaV4')
    .then(counter => console.log(counter));

    Parameters

    • address: string

      The contract for which to retrieve the counter

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<string>

  • Description

    Get the delegate for a contract

    Returns

    The delegate of a contract, if any

    Example

    tezos.getDelegate('tz1fXdNLZ4jrkjtgJWMcfeNpFDK9mbCBsaV4')
    .then(delegate => console.log(delegate));

    Parameters

    • address: string

      The contract for which to retrieve the delegate

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<string>

  • Description

    List of delegates with their voting weight, in number of rolls

    Returns

    The ballots of the current voting period

    Example

    tezos.getListings().then(listings => console.log(listings));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<any[]>

  • Description

    Get the manager for a contract

    Returns

    The manager of a contract

    Example

    tezos.getManager('tz1fXdNLZ4jrkjtgJWMcfeNpFDK9mbCBsaV4')
    .then(({ manager, key }) => console.log(manager, key));

    Parameters

    • address: string

      The contract for which to retrieve the manager

    • Optional block: string = 'head'

      The block to query against

    Returns Promise<{ key: string; manager: string }>

  • Description

    Current pending operations in the mempool

    Returns

    Pending operations

    Example

    tezos.getPendingOperations().then(({ applied }) => console.log(applied));
    

    Returns Promise<any>

  • Description

    Current proposal under evaluation

    Returns

    Current proposal under evaluation

    Example

    tezos.getProposal().then(currentProposal => console.log(currentProposal));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<string>

  • Description

    Current period kind

    Returns

    Current period kind

    Example

    tezos.getProposalPeriod().then(proposalPeriod => console.log(proposalPeriod));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<any>

  • Description

    List of proposals with number of supporters

    Returns

    List of proposals with number of supporters

    Example

    tezos.getProposals().then(proposals => {
    console.log(proposals[0][0], proposals[0][1])
    console.log(proposals[1][0], proposals[1][1])
    );

    Parameters

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<any[]>

  • Description

    Current expected quorum

    Returns

    Current expected quorum

    Example

    tezos.getQuorum().then(quorum => console.log(quorum));
    

    Parameters

    • Optional block: string | number = 'head'

      The block to query against

    Returns Promise<number>

  • Description

    Import a secret key

    Example

    await tezos.importKey('edskRv6ZnkLQMVustbYHFPNsABu1Js6pEEWyMUFJQTqEZjVCU2WHh8ckcc7YA4uBzPiJjZCsv3pC1NDdV99AnyLzPjSip4uC3y')
    

    Parameters

    • key: string

      The secret key

    • Optional passphrase: string

      The passphrase of the encrypted key

    • Optional email: string

      The email associated with the fundraiser account

    Returns Promise<void>

  • Description

    Import a ledger public key

    Example

    import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
    await tezos.importLedger(TransportNodeHid, "44'/1729'/0'/0'");

    Parameters

    • transport: any

      The ledger transport (https://github.com/LedgerHQ/ledgerjs)

    • Optional path: string = "44'/1729'/0'/0'"

      The ledger path

    • Optional curve: string = 'tz1'

      The curve parameter

    Returns Promise<void>

  • Description

    Inject an operation

    Returns

    Object containing the injected operation hash

    Parameters

    Returns Promise<any>

  • Description

    Looks up a contract and returns an initialized contract

    Returns

    An initialized contract class

    Example

    // Load contract
    const contract = await tezos.loadContract('KT1MKm4ynxPSzRjw26jPSJbaMFTqTc4dVPdK');
    // List defined contract methods
    const { methods } = contract;
    // Retrieve contract storage
    const storage = await contract.storage();
    // Get big map keys
    await storage.ledger.get('tz1P1n8LvweoarK3DTPSnAHtiGVRujhvR2vk');
    // Determine method schema
    await contract.methods.transfer('tz1P1n8LvweoarK3DTPSnAHtiGVRujhvR2vk', 100).schema();
    // Send contract operation
    await contract.methods.transfer('tz1P1n8LvweoarK3DTPSnAHtiGVRujhvR2vk', 100).send({
    fee: '100000',
    gasLimit: '800000',
    storageLimit: '60000',
    });

    Parameters

    • address: string

      The contract address

    Returns Promise<Contract>

  • Description

    Originate a new contract

    Returns

    Object containing the injected operation hash

    Parameters

    Returns Promise<any>

  • Description

    Prepares an operation

    Returns

    Object containing the prepared operation

    Example

    tezos.prepareOperation({
    operation: {
    kind: 'transaction',
    fee: 1420,
    gas_limit: 10600,
    storage_limit: 300,
    amount: 1000,
    destination: 'tz1RvhdZ5pcjD19vCCK9PgZpnmErTba3dsBs',
    }
    }).then(({ opbytes, opOb, counter }) => console.log(opbytes, opOb, counter));

    Parameters

    Returns Promise<<internal>.ForgedBytes>

  • Description

    Queries a node given a path and payload

    Returns

    The response of the query

    Example

    sotez.query(/chains/main/blocks/head) .then(head => console.log(head));

    Parameters

    • path: string

      The RPC path to query

    • Optional payload: any

      The payload of the query

    • Optional method: string

      The request method. Either 'GET' or 'POST'

    Returns Promise<any>

  • Description

    Register an account as a delegate

    Returns

    Object containing the injected operation hash

    Parameters

    • paramObject: { fee?: number; gasLimit?: number; storageLimit?: number } = {}

      The parameters for the operation

      • Optional fee?: number

        The fee to set for the transaction

      • Optional gasLimit?: number

        The gas limit to set for the transaction

      • Optional storageLimit?: number

        The storage limit to set for the transaction

    Returns Promise<any>

  • Description

    Send an operation

    Returns

    Object containing the injected operation hash

    Example

    const operation = {
    kind: 'transaction',
    fee: 1420,
    gas_limit: 10600,
    storage_limit: 300,
    amount: 1000,
    destination: 'tz1RvhdZ5pcjD19vCCK9PgZpnmErTba3dsBs',
    };

    tezos.sendOperation({ operation }).then(result => console.log(result));

    tezos.sendOperation({ operation: [operation, operation] }).then(result => console.log(result));

    Parameters

    Returns Promise<any>

  • Description

    Set a delegate for an account

    Returns

    Object containing the injected operation hash

    Parameters

    • paramObject: { delegate: string; fee?: number; gasLimit?: number; source?: string; storageLimit?: number }

      The parameters for the operation

      • delegate: string

        The delegate for the new account

      • Optional fee?: number

        The fee to set for the transaction

      • Optional gasLimit?: number

        The gas limit to set for the transaction

      • Optional source?: string

        The source address of the operation

      • Optional storageLimit?: number

        The storage limit to set for the transaction

    Returns Promise<any>

  • Parameters

    • provider: string
    • chain: string = ...

    Returns void

  • Description

    Inject an operation without prevalidation

    Returns

    Object containing the injected operation hash

    Parameters

    • sopbytes: string

      The signed operation bytes

    Returns Promise<any>

  • Description

    Simulate an operation

    Returns

    The simulated operation result

    Example

    tezos.simulateOperation({
    operation: {
    kind: 'transaction',
    fee: 1420,
    gas_limit: 10600,
    storage_limit: 300,
    amount: 1000,
    destination: 'tz1RvhdZ5pcjD19vCCK9PgZpnmErTba3dsBs',
    },
    }).then(result => console.log(result));

    Parameters

    Returns Promise<any>

  • Description

    Transfer operation

    Returns

    Object containing the injected operation hash

    Example

    tezos.transfer({
    to: 'tz1RvhdZ5pcjD19vCCK9PgZpnmErTba3dsBs',
    amount: 1000000,
    fee: 1420,
    }).then(result => console.log(result));

    Parameters

    Returns Promise<any>

  • Description

    Typechecks the provided code

    Returns

    Typecheck result

    Parameters

    • code: string | <internal>.Micheline

      The code to typecheck

    • gas: number = 10000

      The the gas limit

    Returns Promise<any>

Generated using TypeDoc