Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Contract

Contracts are accounts associated with Michelson scripts on the Tezos blockchain. They are created with an explicit origination operation and are therefore sometimes called originated accounts. For more information see the Contracts API documentation on tzKT.

remark

The address of a smart contract always starts with the letters "KT1".

Hierarchy

Index

Constructors

constructor

  • new Contract(type: null | AccountTypeParameter, alias: null | string, address: null | string, publicKey: null | string, revealed: boolean, balance: number, counter: number, delegate: null | number, delegationLevel: null | number, delegationTime: null | Date, numContracts: null | number, numActivations: null | number, numDelegations: null | number, numOriginations: null | number, numTransactions: null | number, numReveals: null | number, numMigrations: null | number, firstActivity: null | number, firstActivityTime: null | Date, lastActivity: null | number, lastActivityTime: null | Date, contracts: null | Contract[], operations: null | Operation[], metadata: any): Contract
  • internal

    Parameters

    • type: null | AccountTypeParameter
    • alias: null | string
    • address: null | string
    • publicKey: null | string
    • revealed: boolean
    • balance: number
    • counter: number
    • delegate: null | number
    • delegationLevel: null | number
    • delegationTime: null | Date
    • numContracts: null | number
    • numActivations: null | number
    • numDelegations: null | number
    • numOriginations: null | number
    • numTransactions: null | number
    • numReveals: null | number
    • numMigrations: null | number
    • firstActivity: null | number
    • firstActivityTime: null | Date
    • lastActivity: null | number
    • lastActivityTime: null | Date
    • contracts: null | Contract[]
    • operations: null | Operation[]
    • metadata: any

    Returns Contract

Properties

Readonly address

address: null | string

Readonly alias

alias: null | string

Readonly balance

balance: number

Readonly contracts

contracts: null | Contract[]

Readonly counter

counter: number

Readonly delegate

delegate: null | number

Readonly delegationLevel

delegationLevel: null | number

Readonly delegationTime

delegationTime: null | Date

Readonly firstActivity

firstActivity: null | number

Readonly firstActivityTime

firstActivityTime: null | Date

Readonly lastActivity

lastActivity: null | number

Readonly lastActivityTime

lastActivityTime: null | Date

Readonly metadata

metadata: any

Readonly numActivations

numActivations: null | number

Readonly numContracts

numContracts: null | number

Readonly numDelegations

numDelegations: null | number

Readonly numMigrations

numMigrations: null | number

Readonly numOriginations

numOriginations: null | number

Readonly numReveals

numReveals: null | number

Readonly numTransactions

numTransactions: null | number

Readonly operations

operations: null | Operation[]

Readonly publicKey

publicKey: null | string

Readonly revealed

revealed: boolean

Readonly type

Methods

toString

  • toString(): null | string

Static byAccount

  • Returns a list of contracts created by (or related to) the specified account from tzKT.

    see

    get account by address.

    example

    Fetch Contracts related to an Account

    Usage

    let accountAddress: string = 'tz1WEHHVMWxQUtkWAgrJBFGXjJ5YqZVgfPVE';
    let contracts: Contract[] = await Contract.byAccount(accountAddress);
    

    Parameters

    Returns Promise<Contract[]>

    Returns a list of contracts related to the specified account.

Static byAddress

  • byAddress(address: string, domain?: string): Promise<Contract>
  • Fetches contracts by address from tzKT.

    see

    get contract by address.

    example

    Fetch Contract by Address

    Usage

    let contractAddress: string = 'KT1Sc5aXe5ZADkbdbXSBo2v6wNDgFP9XafRs';
    let contract: Contract = await Contract.byAddress(contractAddress);
    

    Parameters

    • address: string
    • domain: string = 'https://api.tzkt.io'

    Returns Promise<Contract>

    Returns a contract with the specified address.

Static code

  • code(address: string, format: number, domain?: string): Promise<string>
  • Fetches code for the specified contract from tzKT.

    see

    get contract code.

    example

    Fetch Code for a Contract

    Usage

    let contractAddress: string = 'KT1Sc5aXe5ZADkbdbXSBo2v6wNDgFP9XafRs',
        format: number = 2; // return code in bytes
    let contractCode: string = await Contract.code(contractAddress, format);
    

    Parameters

    • address: string
    • format: number
    • domain: string = 'https://api.tzkt.io'

    Returns Promise<string>

    Returns a code of the specified contract.

Static count

  • Fetches a number of contract accounts from tzKT.

    see

    get contracts count.

    example

    Fetch Contract count

    Usage

    let contractCount: number = Contract.count('delegator_contract')
    

    Parameters

    Returns Promise<number>

    Returns a number of contract accounts.

Static fromAPI

Static get

  • Fetches contracts from tzKT.

    see

    get contracts.

    example

    Fetch Contracts

    Usage

    let parameters: GetContractParameters = {'kind': 'delegator_contract', includeStorage: true};
    let contracts: Contract[] = await Contract.get(parameters);
    

    Parameters

    Returns Promise<Contract[]>

    Returns a list of contracts.

Static similar

  • Fetches contracts which have the same interface (parameter and storage types) as the specified one from tzKT.

    remark

    Note, contract parameter and storage types are compared by 32-bit hash, so in very rare cases there may be collisions.

    see

    get similar contracts.

    example

    Fetch Similar Contracts

    Usage

    let contractAddress: string = 'KT1Sc5aXe5ZADkbdbXSBo2v6wNDgFP9XafRs';
    let contracts: Contract[] = await Contract.similar(contractAddress);
    

    Parameters

    • address: string
    • parameters: null | SimilarParameters
    • domain: string = 'https://api.tzkt.io'

    Returns Promise<Contract[]>

    Returns a list of contracts.

Generated using TypeDoc