axie-ronin-ethers-js-tools
Version:
A set of functions that make it easier for developers to interact with their Axies on the Ronin network and the maketplace.
35 lines (28 loc) • 1.29 kB
JavaScript
import { ethers } from 'ethers';
import { cancelMarketplaceOrder } from "axie-ronin-ethers-js-tools";
import 'dotenv/config'
async function cancel() {
if (!process.env.PRIVATE_KEY || !process.env.SKYMAVIS_DAPP_KEY) {
throw new Error('Please set your PRIVATE_KEY and SKYMAVIS_DAPP_KEY in a .env file')
}
// Connect to Ronin network rpc, see https://docs.skymavis.com/ronin/rpc/overview
const connection = {
url: 'https://api-gateway.skymavis.com/rpc',
headers: {
'x-api-key': process.env.SKYMAVIS_DAPP_KEY
}
}
const provider = new ethers.providers.JsonRpcProvider(connection);
// Import the wallet private key from the environment
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider)
// Get address from wallet
const addressFrom = await wallet.getAddress()
console.log(`Wallet address: ${addressFrom}`)
// Get axieId from command line args
const args = process.argv.slice(2)
const axieId = args[0].trim()
// Wait for the transaction to be mined
const receipt = await cancelMarketplaceOrder(axieId, wallet, process.env.SKYMAVIS_DAPP_KEY)
console.log(`You can check the transaction status on https://app.roninchain.com/tx/${receipt.transactionHash}`)
}
cancel();