ERC20 project developed as part of the 42 school curriculum.
Goodies42 (GDS42) is a utility token used to reward students and purchase goodies through a shop contract.
- Name:
Goodies42 - Symbol:
GDS42 - Decimals:
18(fixed) - Standard: ERC20 (
IERC20Metadata) - Target blockchain: Sepolia
Goodies42
├── code/ # token source code and tests
│ ├── contracts/
│ │ └── Goodies42.sol
│ └── test/
│ └── Goodies42.test.ts
├── deployment/ # deployment files
│ └── Modules/
│ └── Goodies42.ts
├── documentation/ # project docs
│ ├── WHITEPAPER_FR.md
│ └── WHITEPAPER_US.md
├── Makefile
├── README.md
├── README_FR.md
└── config files (json, ts, env, gitignore)Configuration files remain at the repository root (hardhat.config.ts, package.json, tsconfig.json) to keep standard Hardhat conventions.
Implements the core ERC20 functions:
transferapprovetransferFrommint(owner only)
Security/ownership:
onlyOwneron sensitive functions- 2-step ownership transfer:
transferOwnershipthenacceptOwnership - ownership can be transferred to a multisig
Handles item purchases through buy:
- on-chain price check via
itemPrice[itemId] - bonus access (
LotteryAccess) if the answer is correct - otherwise transfers token payment to the shop treasury
- max
LotteryAccessper user:3 - admin withdrawal available via
withdrawTokens
Standard dApp flow:
- Student connects wallet (MetaMask) to the dApp.
- dApp reads on-chain price with
itemPrice(itemId). - dApp checks token allowance for
Goodies42Shop. - If allowance is too low, dApp requests
approve(shopAddress, price). - Student confirms the
approvetransaction in wallet. - dApp then sends
buy(itemId, answer). - Student confirms the
buytransaction in wallet. - Contract applies the rule:
- valid bonus: no token payment,
LotteryAccessis consumed - otherwise:
transferFrom(student, shop, price)
- valid bonus: no token payment,
- Backend can confirm purchase by reading the on-chain
ItemPurchasedevent.
Via Makefile:
make install
make compile
make test
make node
make deploy-local
make deploy-sepoliaTo deploy on Sepolia, Hardhat must connect to an Ethereum node through an RPC URL.
- Target blockchain is Sepolia, but access is through an RPC provider (Alchemy, Infura, QuickNode, etc.)
- Without a valid RPC URL, the project cannot read chain state or broadcast deployment transactions
- Public endpoints may exist, but they are often rate-limited or unstable
Required variables:
SEPOLIA_RPC_URL: HTTP URL of the Sepolia RPC providerPRIVATE_KEY: private key of the deployment wallet (dedicated testnet wallet)
Prepare Sepolia environment:
cp .env.example .env
# then fill SEPOLIA_RPC_URL and PRIVATE_KEY in .envWithout Makefile:
npx hardhat compile
npx hardhat test
npx hardhat ignition deploy ./deployment/ignition/modules/Goodies42Core.ts --network localhost
npx hardhat ignition deploy ./deployment/ignition/modules/Goodies42Core.ts --network sepolia- Goodies42 (Sepolia):
0xaDf4D6A3889962F5EF5658a813C75f7c922334ED - Goodies42Shop (Sepolia):
0x15a97d74EC9aE403E791B9A59F8656dE8a6Cc750 - Etherscan link:
https://sepolia.etherscan.io/address/0x15a97d74EC9aE403E791B9A59F8656dE8a6Cc750#code
See WHITEPAPER FR and WHITEPAPER US.
