Options
All
  • Public
  • Public/Protected
  • All
Menu

A contract represents a Solidity contract that has been compiled with Solang to be deployed on Solana.

Hierarchy

  • Contract

Indexable

[name: string]: ContractFunction | any

Functions that map to the functions declared in the contract ABI

Index

Constructors

constructor

  • new Contract(connection: Connection, program: PublicKey, storage: PublicKey, abi: ABI, payer?: null | Signer): Contract

Properties

Readonly abi

abi: ABI

Application Binary Interface in JSON form

Readonly connection

connection: Connection

Connection to use

Readonly functions

functions: Record<string, ContractFunction>

Callable functions mapped to the interface

Readonly interface

interface: Interface

Ethers.js interface parsed from the ABI

payer

payer: null | Signer

Payer for transactions and storage (optional)

Readonly program

program: PublicKey

Account the program is located at (aka Program ID)

Readonly storage

storage: PublicKey

Account the program's data is stored at

Methods

addEventListener

  • Add a listener for contract events

    Parameters

    Returns number

    ID of the listener (pass to removeEventListener to stop listening)

addLogListener

  • Add a listener for log messages

    Parameters

    Returns number

    ID of the listener (pass to removeLogListener to stop listening)

connect

  • Set the payer for transactions and storage

    Parameters

    • payer: Signer

      Payer for transactions and storage

    Returns Contract

    Contract itself (for method chaining)

deploy

  • Deploy the contract to a loaded Solana program.

    Parameters

    • name: string

      Name of the contract to deploy

    • constructorArgs: any[]

      Arguments to pass to the contract's Solidity constructor function

    • storage: Signer

      Keypair for the account the program's data is stored at

    • space: number

      Byte size to allocate for the storage account (this cannot be resized)

    • Optional options: ContractCallOptions

      Accounts, signers, and other parameters for calling the contract constructor

    Returns Promise<ContractCallResult>

    Result of the contract constructor call

disconnect

load

  • load(program: Signer, so: Buffer, payer?: null | Signer): Promise<void>
  • Load the contract's BPF bytecode as a Solana program.

    Parameters

    • program: Signer

      Keypair for the account the program is located at

    • so: Buffer

      ELF .so file produced by compiling the contract with Solang

    • Optional payer: null | Signer

      Payer for transactions and storage (defaults to the payer provided in the constructor)

    Returns Promise<void>

removeEventListener

  • removeEventListener(listenerId: number): Promise<void>
  • Remove a listener for contract events

    Parameters

    • listenerId: number

      ID of the listener (returned by addEventListener)

    Returns Promise<void>

removeLogListener

  • removeLogListener(listenerId: number): Promise<void>
  • Remove a listener for log messages

    Parameters

    • listenerId: number

      ID of the listener (returned by addLogListener)

    Returns Promise<void>

Generated using TypeDoc