Contract Development
Write and deploy EVM contracts
Set up Environment
Contract Design
Contract Logic
EIP20Interface public token; // support token address
uint public nextPacketId; // the next redpacket ID
// packetId -> Packet, store all the redpacket
mapping(uint => Packet) public packets;
//packetId -> address -> bool, store receive redpacket record
mapping(uint => mapping(address => bool)) public receiveRecords;
struct Packet {
uint[] assetAmounts;// Number of tokens per copy
uint receivedIndex; // Number of red packets received
}Define Contract Events
Define Functions
Compile and Test Contract using Hardhat
Create a Hardhat Project
Configure hardhat.config
File Preparation
Include Code in the test Folder
Compile Contract
Test Contract
Web3 APILast updated