Compare commits

..

2 Commits

Author SHA1 Message Date
Moon Man a4fcf451f5 script to set default royalty info 2023-01-30 13:44:57 -05:00
Moon Man c2b3b04df7 better output 2023-01-30 13:44:41 -05:00
2 changed files with 37 additions and 2 deletions

View File

@ -8,8 +8,11 @@ module.exports = async (callback) => {
console.log(`Name: "${name}", symbol: "${symbol}"`); console.log(`Name: "${name}", symbol: "${symbol}"`);
const royaltyInfo = await wrapper.royaltyInfo(1, "10000000000"); const { 0:receiver, 1:hexAmount} = await wrapper.royaltyInfo(1, "1000000000000000000");
console.log(JSON.stringify(royaltyInfo, null, 4)); console.log(`Default royalty recipient: ${receiver}`);
const ubiqAmount = web3.utils.fromWei(hexAmount, "ether");
console.log(`Royalty on a 1 Ubiq fee: ${ubiqAmount}`);
callback(); callback();
} }

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