1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // We require the Hardhat Runtime Environment explicitly here. This is optional
- // but useful for running the script in a standalone fashion through `node <script>`.
- //
- // When running the script with `npx hardhat run <script>` you'll find the Hardhat
- // Runtime Environment's members available in the global scope.
- const hre = require("hardhat");
- async function main() {
- // Hardhat always runs the compile task when running scripts with its command
- // line interface.
- //
- // If this script is run directly using `node` you may want to call compile
- // manually to make sure everything is compiled
- // await hre.run('compile');
- // We get the contract to deployi
- const RedPacket = await hre.ethers.getContractFactory("HappyRedPacket");
- const redPacket = await RedPacket.deploy();
- await redPacket.deployed();
- redPacket.on("CreationSuccess", (received_amount, _id, _name, _message, msg_sender, block_timestamp, _token_addr, number, ifrandom, duration) => {
- console.log("CreationSuccess ->", received_amount, _id, _name, _message, msg_sender, block_timestamp, _token_addr, number, ifrandom, duration);
- console.log("CreationSuccess id ->", _id);
- });
- const ret = await redPacket.create_red_packet
- ("0x5FbDB2315678afecb367f032d93F642f64180aa3"
- , 1
- , false
- , 10000
- ,"0x36549bd2558d9f37204f55be93cc38db93f377217b306febb9899c0013735755"
- , "good luck"
- , "good luck"
- , 0
- , "0x0000000000000000000000000000000000000000"
- , 1
- , { gasLimit: 310000, value: 1 })
- console.log("RedPacket deployed to:", redPacket.address);
- }
- // We recommend this pattern to be able to use async/await everywhere
- // and properly handle errors.
- main()
- .then(() => process.exit(0))
- .catch((error) => {
- console.error(error);
- process.exit(1);
- });
|