From bd2cb5aea91359778bd1018c38d887a94522457e Mon Sep 17 00:00:00 2001 From: Moon Date: Mon, 30 Jan 2023 14:33:15 -0500 Subject: [PATCH] xfer script --- scripts/transfer-wrapped.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/transfer-wrapped.js diff --git a/scripts/transfer-wrapped.js b/scripts/transfer-wrapped.js new file mode 100644 index 0000000..e2601d4 --- /dev/null +++ b/scripts/transfer-wrapped.js @@ -0,0 +1,32 @@ +const Wrapper = artifacts.require("CurioERC1155Wrapper"); + +module.exports = async (callback) => { + const nftId1 = parseInt(process.argv[6]); + const quantity1 = BigInt(process.argv[7]); + const to = process.argv[8]; + + if (/0x[0-9a-fA-F]{40}/.test(to)) { + const wrapper = await Wrapper.deployed(); + + const [account,] = await web3.eth.getAccounts(); + + const currentBalance = BigInt(await wrapper.balanceOf(account, nftId1)); + console.log(`Current balance: ${currentBalance}`); + + if (currentBalance >= quantity1) { + console.log("Executing transfer transaction..."); + try { + const result = await wrapper.safeTransferFrom(account, to, nftId1, quantity1.toString(), []); + console.log(`Transaction: ${result.tx}`); + } + catch (e) { + console.error(`FAILED: ${e}`); + } + } + else { + console.error("Insufficient balance"); + } + } + + callback(); +}