Configurez votre environnement et déployez un contrat sur le Plasma Testnet avec Hardhat ou Foundry.
Ce guide couvre la configuration de l’environnement, le déploiement de contrats et l’interaction avec le testnet compatible EVM de Plasma en utilisant Hardhat. Il suppose une familiarité de base avec les outils Ethereum et le développement de smart contracts.
Suivez les étapes pour créer un projet JavaScript. Sauvegardez le projet où vous voulez. Vous n’avez probablement pas besoin d’un fichier .gitignore pour ce démarrage rapide.
Configurez hardhat.config.js pour le testnet Plasma :
require("@nomicfoundation/hardhat-toolbox");require("dotenv").config();/** @type import('hardhat/config').HardhatUserConfig */module.exports = { solidity: "0.8.28", networks: { plasmaTestnet: { url: process.env.RPC_ENDPOINT, chainId: 9746, accounts: [process.env.PRIVATE_KEY] // We'll set this up next. } }};
const { expect } = require("chai");describe("SimpleStorage", function () { let simpleStorage; beforeEach(async function () { const SimpleStorage = await ethers.getContractFactory("SimpleStorage"); simpleStorage = await SimpleStorage.deploy(); await simpleStorage.waitForDeployment(); }); it("Should return the initial greeting", async function () { expect(await simpleStorage.getData()).to.equal("Hello, Plasma!"); }); it("Should update the stored data", async function () { await simpleStorage.setData("Updated data"); expect(await simpleStorage.getData()).to.equal("Updated data"); });});
Exécutez les tests :
npx hardhat test
Cela devrait produire quelque chose comme :
Lock Deployment ✔ Should set the right unlockTime (454ms) ✔ Should set the right owner ✔ Should receive and store the funds to lock ✔ Should fail if the unlockTime is not in the future Withdrawals Validations ✔ Should revert with the right error if called too soon ✔ Should revert with the right error if called from another account ✔ Shouldn't fail if the unlockTime has arrived and the owner calls it Events ✔ Should emit an event on withdrawals Transfers ✔ Should transfer the funds to the ownerSimpleStorage ✔ Should return the initial greeting ✔ Should update the stored data11 passing (541ms)