Avocado integration setup

Use the following code to set up the basic interaction structure with Avocado.

import { ethers } from "ethers"; // ethers@v5
import avocadoV1ABI from "./avocado-v1-abi.json";
import avoForwarderV1ABI from "./avo-forwarder-v1-abi.json";

const avocadoProvider = new ethers.providers.JsonRpcProvider("https://rpc.avocado.instadapp.io");
// can use any other RPC on the network you want to interact with:
const polygonProvider = new ethers.providers.JsonRpcProvider("https://polygon-rpc.com");

// Should be connected to chainId 634 (https://rpc.avocado.instadapp.io), before doing any transaction
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();

const avoForwarderAddress = "0x46978CD477A496028A18c02F07ab7F35EDBa5A54"; // available on 10+ networks

// set up AvoForwarder contract (main interaction point) on e.g. Polygon
const forwarder = new ethers.Contract(avoForwarderAddress, avoForwarderV1ABI, polygonProvider);

You can find the ABI files here: