Configura tu entorno y despliega un contrato en la Testnet de Plasma con Hardhat o Foundry.
Esta guía cubre la configuración del entorno, el despliegue de contratos y la interacción con la testnet compatible con EVM de Plasma usando Hardhat. Asume familiaridad básica con el tooling de Ethereum y el desarrollo de smart contracts.
Sigue los pasos para crear un proyecto JavaScript. Guarda el proyecto donde quieras. Probablemente no necesites un archivo .gitignore para este quickstart.
Configura hardhat.config.js para la testnet de 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"); });});
Ejecuta las pruebas:
npx hardhat test
Esto debería generar algo como:
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)