Loan - Liquidate
Loan - Liquidate
Code Example
javascriptCopy code// Import web3js library
import Web3 from 'web3';
import ApproveTradeABI from '../abi/ApproveTrade.json';
// This example is tested on the Polygon-Amoy chain
const amoy_chainId = 80002;
const amoy_chainName = "AMOY";
const amoy_chainRpcUrl = "https://polygon-amoy.infura.io/v3/4ba314367838400fb88f2a1d0e14d42d";
const amoy_contract_ApproveTrade = "0xF1831ebb3f92A8607E644A1E54Fde4b09F6FE5dE";
const amoy_account = "0xA3932E6Dbf96983Ffdf43974c0BF7edE9fed76DF";
// Initialize web3 instance
// WalletProvider or HttpProvider
const web3 = new Web3("** Wallet **"); // window.ethereum
const Contract = new web3.eth.Contract(ApproveTradeABI, amoy_contract_ApproveTrade);
// 1. Liquidation Parameters
// Parameters are retrieved from the creator's history API.
// -- `orderHash` can be found in the `f_order_hash` field.
const orderHash = "0x5973f68a96d2b67e9fb647b3f9c916c95ad308dd18cc06a7e70b27c3abcb70aa";
// 2. Initiate Liquidation Operation
const handleLiquidate = Contract.methods.liquidate([
orderHash
]).send({
from: amoy_account,
});
handleLiquidate.then(receipt => {
console.log(receipt);
}).catch(error => {
console.log(error);
});Key Notes:
Last updated