diff --git a/examples/hello/contracts/Revert.sol b/examples/hello/contracts/Revert.sol new file mode 100644 index 00000000..aa0b821e --- /dev/null +++ b/examples/hello/contracts/Revert.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.26; + +import {RevertContext} from "@zetachain/protocol-contracts/contracts/Revert.sol"; + +contract Revert { + event RevertEvent(string, RevertContext); + event HelloEvent(string, string); + + function hello(string memory message) external { + emit HelloEvent("Hello on EVM", message); + } + + function onRevert(RevertContext calldata revertContext) external { + emit RevertEvent("Revert on EVM", revertContext); + } + + receive() external payable {} + + fallback() external payable {} +} diff --git a/examples/hello/tasks/deployRevert.ts b/examples/hello/tasks/deployRevert.ts new file mode 100644 index 00000000..080808c7 --- /dev/null +++ b/examples/hello/tasks/deployRevert.ts @@ -0,0 +1,31 @@ +import { task, types } from "hardhat/config"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; + +const main = async (args: any, hre: HardhatRuntimeEnvironment) => { + const network = hre.network.name; + + const [signer] = await hre.ethers.getSigners(); + if (signer === undefined) { + throw new Error( + `Wallet not found. Please, run "npx hardhat account --save" or set PRIVATE_KEY env variable (for example, in a .env file)` + ); + } + + const factory = await hre.ethers.getContractFactory(args.name); + const contract = await (factory as any).deploy(); + await contract.deployed(); + + if (args.json) { + console.log(JSON.stringify(contract)); + } else { + console.log(`🔑 Using account: ${signer.address} + +🚀 Successfully deployed "${args.name}" contract on ${network}. +📜 Contract address: ${contract.address} +`); + } +}; + +task("deploy-revert", "Deploy the contract", main) + .addFlag("json", "Output in JSON") + .addOptionalParam("name", "Contract to deploy", "Revert");