Class Multicall

Hierarchy

  • Multicall

Constructors

Properties

Methods

Constructors

  • Example

    const tokens = [
    "19GYjDBVXU7keLbYvMLazsGQn3GTWHjHkK", // koin
    "12Y5vW6gk8GceH53YfRkRre2Rrcsgw7Naq", // vhp
    "12VoHz41a4HtfiyhTWbg9RXqGMRbYk6pXh", // vortex usdt
    "1Tf1QKv3gVYLjq34yURSHw5ErTYbFjqTG", // vortex eth
    ];

    const provider = new Provider("https://api.koinos.io");

    // create an array of the different contracts
    // used in the multicall
    const contracts = [];
    for (const token of tokens) {
    contracts.push(
    new Contract({
    id: token,
    provider,
    abi: utils.tokenAbi,
    })
    );
    }

    // create the multicall instance
    const multicall = new Multicall({
    provider,
    contracts
    });

    // add operations to the multicall
    for (const contract of contracts) {
    await multicall.add(contract.functions.balanceOf, {
    owner: "1MdqwaSBy6rbasPJ9vmg2pZFJSVZ29GFpZ",
    });
    }

    // call the multicall
    const results = await multicall.call();
    console.log(results);

    For testnet set the id to the multicall contract address for testnet

    const multicall = new Multicall({
    id: "1MM9ydA8SdgXvCTH3LdQ5FS8JvHijCmGSg",
    provider: new Provider("https://testnet-api.koinos.io"),
    contracts: [ koinContract, fogataPoolContract ],
    });

    Parameters

    • c: { contracts?: Contract[]; id?: string; provider?: ProviderInterface }
      • Optional contracts?: Contract[]
      • Optional id?: string

        Multicall contract address. Leave it undefined to use the mainnet multicall contract address.

      • Optional provider?: ProviderInterface

    Returns Multicall

Properties

contracts: Contract[]
id: string

Multicall contract address

transaction: Transaction

Methods

  • Type Parameters

    • T = Record<string, unknown>

    Returns Promise<(Error | T)[]>

Generated using TypeDoc