ERC1155 is a multi-token standard that allows the creation of fungible, non-fungible, and semi-fungible tokens all in one contract. Before ERC1155, if a use case needed both ERC20 (fungible) and ERC721 (non-fungible) tokens, then separate contracts were required to achieve this. ERC1155 also allows for multiple NFT collections to be launched in just one smart contract instead of creating a different contract for each collection; this increases efficiency in smart contract construction and minimizes the transaction count, which is very important as it consumes less blockchain space. With ERC1155, batch transfer of tokens is also possible instead of transferring a token to a single address in previous standards.
- Demo contract
- Deploy script
- Crontab script
- Create new lotto [For owner]
- Draw winning numbers [For owner]
- Buy lotto ticket
- Claim reward
- Withdraw all [For owner]
- Generate random number [For Lottery]
- Mint NFT
To get started with this boilerplate, you just need to follow these simple steps:
-
Upload demo NFT logo for use on Pinata
-
Deploy demo contract with script
npx hardhat run --network sepolia scripts/gambling/deploy_lottery.js
-
Operate and observe data changes to understand contract features
- Create new lotto
- Buy ticket
- Draw winning numbers
- Claim reward
-
Write workflows to automate lotto creation and draws with GitHub Actions
Since each operation consumes ETH, these functions are moved to the UI for easy operation.
name: Create New Lotto and Draw Winning Numbers on: schedule: # 第一个定时任务: 每周一早上1点 - cron: "0 1 * * 1" # 第二个定时任务: 每周六早上1点 - cron: "0 1 * * 6" jobs: job1: name: Create New Lotto runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v3 - name: Run daily task run: npx hardhat run --network sepolia scripts/gambling/new_lotto.js job2: name: Draw Winning Numbers runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v3 - name: Run weekly task run: npx hardhat run --network sepolia scripts/gambling/draw_winning_numbers.js
By MIT licensed.