Skip to content

Instantly share code, notes, and snippets.

@thaarok
Created October 18, 2021 20:15
Show Gist options
  • Save thaarok/c23d8be8aa4abc3e25b9162139685292 to your computer and use it in GitHub Desktop.
Save thaarok/c23d8be8aa4abc3e25b9162139685292 to your computer and use it in GitHub Desktop.
Tool for minting (cloning) Artion tokens
<script src="//cdnjs.cloudflare.com/ajax/libs/web3/1.6.0/web3.min.js" integrity="sha512-+BhnLgfzIDDjssoEWHPmdgWRvbwIEdj0Xfiys7uSqfQWpMEOJ4ymJ88O6B1cB0j+4zjb5GhO+sb/kEicggvUQQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<h2>Mint token</h2>
Token contract (collection):</br>
<input type="text" id="contract" value="0x61af4d29f672e27a097291f72fc571304bc93521" style="width: 50em"></br>
Beneficiary (who obtains new tokens):</br>
<input type="text" id="beneficiary" value="0x83a6524be9213b1ce36bcc0dcefb5eb51d87ad10" style="width: 50em"></br>
Metadata JSON URI:</br>
<input type="text" id="uri" value="https://artion10.mypinata.cloud/ipfs/QmPo8sQz4Lj9rVp71yaoTWCxZzS2vpPFmYEAaD1aph3RQu" style="width: 50em"></br>
Amount of tokens to mint:</br>
<input type="text" id="tokens" value="2" style="width: 15em"></br>
<input type="button" value="Mint tokens" onclick="mint()"><br>
<script>
const abi = [
{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_auction","type":"address"},{"internalType":"address","name":"_marketplace","type":"address"},{"internalType":"address","name":"_bundleMarketplace","type":"address"},{"internalType":"uint256","name":"_platformFee","type":"uint256"},{"internalType":"address payable","name":"_feeReceipient","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},
{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},
{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},
{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"string","name":"tokenUri","type":"string"},{"indexed":false,"internalType":"address","name":"minter","type":"address"}],"name":"Minted","type":"event"},
{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},
{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},
{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address payable","name":"feeRecipient","type":"address"}],"name":"UpdateFeeRecipient","type":"event"},
{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"platformFee","type":"uint256"}],"name":"UpdatePlatformFee","type":"event"},
{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},
{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[],"name":"feeReceipient","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"string","name":"_tokenUri","type":"string"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},
{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},
{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},
{"inputs":[],"name":"platformFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},
{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},
{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},
{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},
{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"address payable","name":"_feeReceipient","type":"address"}],"name":"updateFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},
{"inputs":[{"internalType":"uint256","name":"_platformFee","type":"uint256"}],"name":"updatePlatformFee","outputs":[],"stateMutability":"nonpayable","type":"function"}
];
let sentMints = 0;
let confirmedMints = 0;
async function mint() {
let web3 = new Web3(window.ethereum);
let accounts = await web3.eth.requestAccounts();
if(!accounts) {
alert("No account selected!");
return;
}
console.log('mint...');
let contractt = new web3.eth.Contract(abi, contract.value, {
from: accounts[0] // default from address
});
let platformFee = await contractt.methods.platformFee().call();
console.log('platformFee', platformFee);
// mint(_to address, _tokenUri string)
let trans = contractt.methods.mint(beneficiary.value, uri.value);
let gas = await trans.estimateGas({
from: accounts[0],
value: platformFee,
});
console.log('gas', gas);
let gasPrice = await web3.eth.getGasPrice();
console.log('gasPrice', gasPrice);
for (let i = 0; i < parseInt(tokens.value); i++) {
trans.send({
from: accounts[0],
value: platformFee,
gasPrice: gasPrice,
gas: gas,
}).on('receipt', function(receipt){
console.log('confirmedMints', ++confirmedMints);
});
console.log('sentMints', ++sentMints);
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment