Create an abi.json file under the "src" directory, the content of which can be founded on .
import the file in App.jsx
import abi from './abi.json'
Call a contract
Import "ethers" and create a method "getContractInstance" to acquire a "contract" instance so that it can be used to call a contract. Note that the contract in this example is deployed on the mumbai network, so make sure that Metamask is switched to this network.
import { ethers, providers } from 'ethers'
// The name to be registered
const registerName = 'test-' + Date.now()
const getContractInstance = () => {
// The contract address
const contractAddress = '0x6A22794A1e2aBdEC057a6dc24A6BFB53F9518016'
const provider = new providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, abi, signer)
return contract
}