diff --git a/migrations/3_send.js b/migrations/3_send.js new file mode 100644 index 0000000..18c2730 --- /dev/null +++ b/migrations/3_send.js @@ -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())); +}; diff --git a/package.json b/package.json index e91b78c..7bd1503 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/1_send_to_winers.js b/scripts/1_send_to_winers.js index 08f95c5..7aeaba5 100644 --- a/scripts/1_send_to_winers.js +++ b/scripts/1_send_to_winers.js @@ -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()