Skip to content

Commit

Permalink
added script for mint(), sendToWinners().
Browse files Browse the repository at this point in the history
  • Loading branch information
anupam-io committed Mar 28, 2021
1 parent 85be973 commit 2b90ef7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
15 changes: 15 additions & 0 deletions migrations/3_send.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Mushroom = artifacts.require("Mushroom");
const MushroomReceiver = artifacts.require("MushroomReceiver");

module.exports = async function (deployer) {
let mush = await Mushroom.deployed();
let mushR = await MushroomReceiver.deployed();

const account = (await web3.eth.getAccounts())[0];
await mush.mint(mushR.address);
await mushR.sendToWinners(mush.address, account, 0, (20).toString());

await mush
.balanceOf(account, 0)
.then((d) => console.log("My balance: ", d.toString()));
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"migrate": "truffle migrate --reset --network rinkeby",
"verify:m": "truffle run verify Mushroom --network rinkeby --license MIT",
"verify:r": "truffle run verify MushroomReceiver --network rinkeby --license MIT",
"test": "truffle test;"
"test": "truffle test;",
"start": ""
},
"dependencies": {
"@openzeppelin/contracts": "^4.0.0",
Expand Down
22 changes: 9 additions & 13 deletions scripts/1_send_to_winers.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
const Mushroom = artifacts.require("Mushroom");
const MushroomReceiver = artifacts.require("MushroomReceiver");

module.exports = async function () {
const Mushroom = await artifacts.require("Mushroom").deployed();
const MushroomReceiver = await artifacts.require("MushroomReceiver").deployed();
const mush = new web3.eth.Contract(Mushroom.abi, Mushroom.address);
const mushR = new web3.eth.Contract(MushroomReceiver.abi, MushroomReceiver.address);

module.exports = async function (){
mush = await Mushroom.deployed();
mushR = await MushroomReceiver.deployed();

console.log(mush);
console.log(mushR);
const accounts = await web3.eth.getAccounts();

// myAccount = (await web3.eth.getAccounts())[0];
// await mush.mint(mushR.address);
// await mushR.sendToWinners(mush.address, myAccount, 0, (10).toString());
}
// Create the token via mint()
await mush.methods.mint(mushR).send({from: accounts[0]});

};
// Create the token via mint()

// Distribute the token via sendToWinners()

0 comments on commit 2b90ef7

Please sign in to comment.