Direct Contract Interaction
Prerequisites
Step 1: Install Ethers.js
npm install ethersStep 2: Connect to the Network that You'd Like to Add Liquidity to
const ethers = require('ethers');
const provider = ethers.getDefaultProvider();Step 3: Import the Contract ABI and Address
const contractABI = [
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
];
const contractAddress = '' // fill with the relay contract addressStep 4: Create a Contract Instance
Step 5: Create a Signer
Step 6: Connect Contract to Signer
Step 7: Interact with the Contract
Deposit:
Withdraw:
❗️❗️ Please review the following information before implementation❗️❗️
Last updated