Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Contract

Provides a dynamically created interface to interact with Ethereum contracts via weiroll.

Once created using the constructor or the Contract.createContract or Contract.createLibrary functions, the returned object is automatically populated with methods that match those on the supplied contract. For instance, if your contract has a method add(uint, uint), you can call it on the Contract object:

// Assumes `Math` is an ethers.js Contract instance.
const math = Contract.createLibrary(Math);
const result = math.add(1, 2);

Calling a contract function returns a FunctionCall object, which you can pass to Planner.add, Planner.addSubplan, or Planner.replaceState to add to the sequence of calls to plan.

Hierarchy

  • BaseContract
    • Contract

Indexable

[key: string]: ContractFunction | any

Index

Constructors

constructor

  • new Contract(address: string, contractInterface: ContractInterface, commandflags?: CommandFlags): Contract
  • Parameters

    • address: string

      The address of the contract

    • contractInterface: ContractInterface

      The ethers.js Interface representing the contract

    • commandflags: CommandFlags = 0

      Optional flags specifying the default execution options for all functions

    Returns Contract

Properties

Readonly address

address: string

The address of the contract

Readonly commandflags

commandflags: CommandFlags

Flags specifying the default execution options for all functions

Readonly functions

functions: {}

A mapping from function names to ContractFunctions.

Type declaration

Readonly interface

interface: Interface

The ethers.js Interface representing the contract

Methods

Static createContract

  • Creates a Contract object from an ethers.js contract. All calls on the returned object will default to being standard CALL operations. Use this when you want your weiroll script to call a standard external contract.

    Parameters

    • contract: Contract

      The ethers.js Contract object to wrap.

    • commandflags: CommandFlags = ...

      Optionally specifies a non-default call type to use, such as CommandFlags.STATICCALL.

    Returns Contract

Static createLibrary

  • createLibrary(contract: Contract): Contract
  • Creates a Contract object from an ethers.js contract. All calls on the returned object will default to being DELEGATECALL operations. Use this when you want your weiroll script to call a library specifically designed for use with weiroll.

    Parameters

    • contract: Contract

      The ethers.js Contract object to wrap.

    Returns Contract

Generated using TypeDoc