Настройте окружение и разверните контракт на Plasma Testnet с помощью Hardhat или Foundry.
Это руководство охватывает настройку окружения, развёртывание контракта и взаимодействие с EVM-совместимым testnet Plasma с использованием Hardhat. Предполагается базовое знакомство с инструментами Ethereum и разработкой смарт-контрактов.
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"); });});
Запустите тесты:
npx hardhat test
Вывод должен быть примерно такой:
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)