Skip to content

Commit

Permalink
πŸ“ŠπŸ€ ↣ Adding token airdrop conditions for #32 #35 #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Gizmotronn committed Nov 23, 2022
1 parent cfca156 commit 16cff8f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/5-deploy-token.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { AddressZero } from "@ethersproject/constants";
import sdk from './1-initialize-sdk.mjs';

(async () => {
try {
const tokenAddress = await sdk.deployer.deployToken({
name: "Star Sailors Governance Token",
symbol: "SAILOR",
primary_sale_recipient: AddressZero,
});
console.log("βœ… Successfully deployed token contract. Address: ", tokenAddress,);
} catch (error) {
console.error("Failed to deploy token contract. Error: ", error);
}
})();

/* Output
πŸ‘‹ -> SDK Initialised by address: 0x15A4C3b42f3386Cd1A642908525469684Cac7C6d
βœ… Successfully deployed token contract. Address: 0x6e4A2c27a080ae51C825e7b08D753D8851F9a455
*/
13 changes: 13 additions & 0 deletions scripts/6-print-tokens.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sdk from "./1-initialize-sdk.mjs";

(async () => {
try {
const token = await sdk.getContract("0x6e4A2c27a080ae51C825e7b08D753D8851F9a455", 'token');
const amount = 1_000_000;
await token.mint(amount);
const totalSupply = await token.totalSupply();
console.log("βœ… There now are ", totalSupply.displayValue, " $SAILORS in circulation");
} catch (error) {
console.error("Failed to print tokens, ", error);
}
})();
42 changes: 42 additions & 0 deletions scripts/7-airdrop-token.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import sdk from "./1-initialize-sdk.mjs";

(async () => {
try {
// This is the address to our ERC-1155 membership NFT contract.
const editionDrop = await sdk.getContract("0x93FC4ba29c41c059fB9f4727F3903df776771Af8", "edition-drop");
// This is the address to our ERC-20 token contract.
const token = await sdk.getContract("0x6e4A2c27a080ae51C825e7b08D753D8851F9a455", "token");
// Grab all the addresses of people who own our membership NFT, which has
// a tokenId of 0.
const walletAddresses = await editionDrop.history.getAllClaimerAddresses(0);

if (walletAddresses.length === 0) {
console.log(
"No NFTs have been claimed yet, maybe get some friends to claim your free NFTs!",
);
process.exit(0);
}

// Loop through the array of addresses.
const airdropTargets = walletAddresses.map((address) => {
// Pick a random # between 1000 and 10000.
const randomAmount = Math.floor(Math.random() * (10000 - 1000 + 1) + 1000);
console.log("βœ… Going to airdrop", randomAmount, "tokens to", address);

// Set up the target.
const airdropTarget = {
toAddress: address,
amount: randomAmount,
};

return airdropTarget;
});

// Call transferBatch on all our airdrop targets.
console.log("🌈 Starting airdrop...");
await token.transferBatch(airdropTargets);
console.log("βœ… Successfully airdropped tokens to all the holders of the NFT!");
} catch (err) {
console.error("Failed to airdrop tokens", err);
}
})();

0 comments on commit 16cff8f

Please sign in to comment.