curio-wrapper-truffle/scripts/set-royalties.js

33 lines
945 B
JavaScript
Raw Normal View History

2023-01-30 18:44:57 +00:00
const Wrapper = artifacts.require("CurioERC1155Wrapper");
const MAX = 7.5;
module.exports = async (callback) => {
const receiver = process.argv[6];
if (/0x[0-9a-fA-F]{40}/.test(receiver)) {
const percentage = parseFloat(process.argv[7]);
if (percentage > 0 && percentage <= MAX) {
const numerator = Math.ceil(percentage * 100);
console.log(`Numerator to be used: ${numerator}`);
const wrapper = await Wrapper.deployed();
console.log("Exeuting transaction...");
try {
await wrapper.setDefaultRoyalty(receiver, numerator);
}
catch (e) {
console.error(`FAILED: ${e}`);
}
}
else {
console.error(`Royalty must be greater than zero and less than %${percentage}`);
}
}
else {
console.error("Invalid receiver address");
}
callback();
}