Compare commits

..

2 Commits

Author SHA1 Message Date
Moon Man bd2cb5aea9 xfer script 2023-01-30 14:33:15 -05:00
Moon Man 363d783f42 can specify different account 2023-01-30 14:32:53 -05:00
2 changed files with 36 additions and 2 deletions

View File

@ -12,8 +12,10 @@ module.exports = async (callback) => {
const [account,] = await web3.eth.getAccounts(); const [account,] = await web3.eth.getAccounts();
const wrappedBalance1 = await wrapper.balanceOf(account, nftId1); const whom = process.argv[7] ? process.argv[7] : account;
const tokenBalance1 = await tokenContract1.balanceOf(account);
const wrappedBalance1 = await wrapper.balanceOf(whom, nftId1);
const tokenBalance1 = await tokenContract1.balanceOf(whom);
console.log(`Wrapped: ${wrappedBalance1}`); console.log(`Wrapped: ${wrappedBalance1}`);
console.log(`Unwrapped: ${tokenBalance1}`); console.log(`Unwrapped: ${tokenBalance1}`);

View File

@ -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();
}