script to set default royalty info

This commit is contained in:
Moon Man 2023-01-30 13:44:57 -05:00
parent c2b3b04df7
commit a4fcf451f5
1 changed files with 32 additions and 0 deletions

32
scripts/set-royalties.js Normal file
View File

@ -0,0 +1,32 @@
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();
}