From 1ee10e1ba0d19c445e115cfa060732aae6d45f03 Mon Sep 17 00:00:00 2001 From: Ladebeze66 Date: Tue, 20 Oct 2026 12:19:21 +0200 Subject: [PATCH] etape3testavantdeploementok --- tokenizerRendu/code/README.md | 8 ++++- tokenizerRendu/code/contracts/FGC42Forge.sol | 17 ++++++++++ tokenizerRendu/code/test/FGC42Forge.ts | 35 ++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tokenizerRendu/code/contracts/FGC42Forge.sol create mode 100644 tokenizerRendu/code/test/FGC42Forge.ts diff --git a/tokenizerRendu/code/README.md b/tokenizerRendu/code/README.md index ffcf75a..47839b4 100644 --- a/tokenizerRendu/code/README.md +++ b/tokenizerRendu/code/README.md @@ -4,7 +4,13 @@ Sources du token **FGC42Forge** (symbole **FG42**), standard **BEP-20**, déploi Stack : **Solidity**, **Hardhat 3**, **OpenZeppelin**, tests **Mocha + ethers** et tests Solidity (`.t.sol`). -> Le contrat `FGC42Forge.sol` sera ajouté à l’étape 3. Le dossier contient encore l’exemple **Counter** généré par `npx hardhat --init`. +### BEP-20 vs `ERC20` dans le code + +- **Rendu / soutenance :** token **BEP-20** sur **BNB Smart Chain Testnet** (chainId 97). +- **Code :** héritage **OpenZeppelin `ERC20`** — norme EVM identique en pratique ; pas de bibliothèque `BEP20` séparée. +- **Après deploy :** BscScan classera le contrat en **BEP-20** ; le source reste `import {ERC20} from "@openzeppelin/contracts/..."`. + +> Le dossier peut encore contenir l’exemple **Counter** (template Hardhat) en attendant nettoyage. ## Prérequis diff --git a/tokenizerRendu/code/contracts/FGC42Forge.sol b/tokenizerRendu/code/contracts/FGC42Forge.sol new file mode 100644 index 0000000..bfadbd4 --- /dev/null +++ b/tokenizerRendu/code/contracts/FGC42Forge.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.34; + +import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; + +/// @title FGC42Forge — jeton fongible pour BNB Smart Chain Testnet +/// @notice Standard **BEP-20** (exigé sur BSC) : même interface que l’ERC-20 sur l’EVM. +/// On importe OpenZeppelin `ERC20` ; après déploiement sur BSC, BscScan affiche un token BEP-20. +/// Phrase soutenance : « BEP-20 sur la chaîne, implémenté via ERC20 OpenZeppelin. » +contract FGC42Forge is ERC20, Ownable { + uint256 private constant INITIAL_SUPPLY = 1_000_000 * (10 ** 18); + + constructor() ERC20("FGC42Forge", "FG42") Ownable(msg.sender) { + _mint(msg.sender, INITIAL_SUPPLY); + } +} \ No newline at end of file diff --git a/tokenizerRendu/code/test/FGC42Forge.ts b/tokenizerRendu/code/test/FGC42Forge.ts new file mode 100644 index 0000000..78db0bb --- /dev/null +++ b/tokenizerRendu/code/test/FGC42Forge.ts @@ -0,0 +1,35 @@ +import { expect } from "chai"; +import { network } from "hardhat"; + +const { ethers } = await network.create(); + +const INITIAL_SUPPLY = 1_000_000n * 10n ** 18n; + +describe("FGC42Forge", function () { + it("expose le nom, le symbole et la supply fixe au déployeur", async function () { + const [deployer] = await ethers.getSigners(); + const token = await ethers.deployContract("FGC42Forge"); + + expect(await token.name()).to.equal("FGC42Forge"); + expect(await token.symbol()).to.equal("FG42"); + expect(await token.decimals()).to.equal(18n); + expect(await token.totalSupply()).to.equal(INITIAL_SUPPLY); + expect(await token.balanceOf(deployer.address)).to.equal(INITIAL_SUPPLY); + expect(await token.owner()).to.equal(deployer.address); + }); + + it("permet un transfer ERC-20 classique", async function () { + const [deployer, recipient] = await ethers.getSigners(); + const token = await ethers.deployContract("FGC42Forge"); + + const amount = 1_000n * 10n ** 18n; + await expect(token.transfer(recipient.address, amount)) + .to.emit(token, "Transfer") + .withArgs(deployer.address, recipient.address, amount); + + expect(await token.balanceOf(recipient.address)).to.equal(amount); + expect(await token.balanceOf(deployer.address)).to.equal( + INITIAL_SUPPLY - amount, + ); + }); +}); \ No newline at end of file