import { task, types } from "hardhat/config";
import type { HardhatRuntimeEnvironment } from "hardhat/types";
const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
const contractArtifact = await hre.artifacts.readArtifact("Hello");
const contract = new hre.ethers.Contract(
args.contract,
contractArtifact.abi,
signer
);
const message = hre.ethers.utils.defaultAbiCoder.encode(
["string"],
[args.message]
);
const revertMessageBytes = hre.ethers.utils.toUtf8Bytes(args.revertMessage);
try {
const tx = await contract.callFromZetaChain(
hre.ethers.utils.hexlify(args.receiver),
args.zrc20,
message,
args.gasLimit,
{
revertAddress: args.revertAddress,
callOnRevert: args.callOnRevert,
abortAddress: "0x0000000000000000000000000000000000000000", // not used
revertMessage: hre.ethers.utils.hexlify(revertMessageBytes),
},
{
gasPrice: 10000000000,
gasLimit: 7000000,
}
);
await tx.wait();
console.log("Successfully called the contract on ZetaChain!");
} catch (e) {
console.error("Error calling contract:", e);
}
};
task(
"call-from-zetachain",
"Calls the callFromZetaChain function on a universal app",
main
)
.addParam("message", "A message")
.addParam("contract", "The address of the universal app on ZetaChain")
.addOptionalParam(
"zrc20",
"The address of the ZRC20 token",
"0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c"
)
.addParam("gasLimit", "The gas limit for the transaction", 7000000, types.int)
.addFlag("callOnRevert", "Whether to call on revert")
.addParam("revertAddress")
.addParam("revertMessage")
.addParam("receiver", "The address of the receiver contract on EVM");
npx hardhat call-from-zetachain --message alice --network localhost --revert-address 0x9A676e781A523b5d0C0e43731313A708CB607508 --revert-message "my revert message" --call-on-revert --contract 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 --receiver 0x9A676e781A523b5d0C0e43731313A708CB607508
Using branch from this PR https://github.com/zeta-chain/localnet/pull/16
Example is
universal/hello
from https://github.com/zeta-chain/example-contracts/pull/189Ts is processed fine in localnet:
But I'm not seeing the event:
And localnet does not
console.log
anything.