Solidity 0.8.24 · Foundry (forge) · Minimal template (no metadata)
Target: Whitechain Testnet (deploy + later verify)
This repo is a starter you can extend to complete the WhiteBIT/NaUKMA assignment.
It compiles, deploys, and includes a passing smoke test. You will implement the game logic incrementally.
- 6 base NFTs: Wood, Iron, Gold, Leather, Stone, Diamond
| Item | Recipe | Optional |
|---|---|---|
| Cossack Sabre | 3×Iron + 1×Wood + 1×Leather | No |
| Elder Staff | 2×Wood + 1×Gold + 1×Diamond | No |
| Charakternyk Armor | 4×Leather + 2×Iron + 1×Gold | Yes |
| Battle Bracelet | 4×Iron + 2×Gold + 2×Diamond | Yes |
- NFTs (ERC1155 & ERC721) must not be minted/burned directly — only via Crafting/Search and Marketplace
- ERC721 items are burned only on Marketplace purchase
- MagicToken (ERC20) is minted only by Marketplace on successful sale
- Player can search every 60 seconds
- Receives 3 random resources (ERC1155)
- Consumes resources (burns ERC1155)
- Mints item (ERC721 with unique ID)
- Sell items (ERC721) for MagicToken
- On purchase:
- Item is burned
- Seller receives freshly minted MagicToken
- Solidity 0.8.24, deployed & verified on Whitechain Testnet
- 100% test coverage
- Deployment via Foundry (or Hardhat)
- NatSpec comments
- README with deployed addresses and run instructions
- Submit PR link to Distedu
.
├── foundry.toml
├── .env.example
├── remappings.txt
├── src/
│ ├── ResourceNFT1155.sol # ERC1155 resources (roles only)
│ ├── ItemNFT721.sol # ERC721 items (role-gated mint, add BURNER_ROLE)
│ ├── MagicToken.sol # ERC20 MAGIC (Marketplace-only mint)
│ ├── CraftingSearch.sol # implement search() & craft()
│ └── Marketplace.sol # implement listing/purchase()
├── script/
│ └── Deploy.s.sol # minimal deploy + role wiring
└── test/
└── Template.t.sol # smoke test (passing)
search():- Enforce 60s cooldown per
msg.sender - Select 3 random resource IDs
[1..6] - Call
ResourceNFT1155.mintBatch(msg.sender, ids, amounts)
- Enforce 60s cooldown per
craft(itemType):- Store recipes (
mapping itemType => (resourceIds, amounts)) - Burn resources via
ResourceNFT1155.burnBatch(...) - Mint item via
ItemNFT721.mintTo(...)
- Store recipes (
- Store listings:
tokenId => (seller, price) list(tokenId, price):- Require
msg.senderis owner - Require
price > 0
- Require
delist(tokenId):- Only seller can delist
purchase(tokenId):- Validate listing & ownership
- Burn item
- Mint
MAGICto seller
Burn Pattern Options:
- Add
burn(uint256)inItemNFT721(role-gated) and grant Marketplace the role - Transfer to Marketplace, then burn as owner
Template hints at Option #1
Add burn role:
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
function burn(uint256 tokenId) external onlyRole(BURNER_ROLE) {
_burn(tokenId);
}Grant BURNER_ROLE to Marketplace in deploy script.
- Uses
MINTER_ROLEandBURNER_ROLE - Only
CraftingSearchcan mint/burn
MARKET_ROLEexists- Only
Marketplacecan mint on successful purchase
https://getfoundry.sh/introduction/installation/
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup
# Clone repo
git clone https://github.com/pyaremenko/whitechain-hw-template.git crypto-hw
cd crypto-hw
# Install dependencies
forge install OpenZeppelin/openzeppelin-contracts@v5.0.2
# Environment
cp .env.example .env.env.example
WHITECHAIN_RPC_URL=https://rpc-testnet.whitechain.io
PRIVATE_KEY=0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaforge clean
forge build -vv
forge test -vv# Dry run
forge script script/Deploy.s.sol:Deploy \
--rpc-url $WHITECHAIN_RPC_URL \
--private-key $PRIVATE_KEY
# Broadcast
forge script script/Deploy.s.sol:Deploy \
--rpc-url $WHITECHAIN_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast -vvv- Implement
search()andcraft()inCraftingSearch.sol - Implement
Marketplacelisting and purchase logic - Add NatSpec comments
- Write full test suite (100% coverage):
- Cooldown logic
- Randomness shape
- ERC1155 mint/burn
- Recipe validation
- ERC721 mint/burn
- Marketplace edge cases
- Reentrancy checks
- Deploy to Whitechain Testnet
- Verify contracts
- Update README with deployed addresses and run instructions