Skip to content

Commit

Permalink
call from zetachain fixes (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito authored Aug 20, 2024
1 parent f7d796b commit 325de30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions universal/hello/contracts/Hello.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {RevertContext, RevertOptions} from "@zetachain/protocol-contracts/contracts/Revert.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/UniversalContract.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IGatewayZEVM.sol";
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol";

contract Hello is UniversalContract {
event HelloEvent(string, string);
Expand Down Expand Up @@ -34,6 +35,7 @@ contract Hello is UniversalContract {
uint256 gasLimit,
RevertOptions memory revertOptions
) external {
IZRC20(zrc20).approve(gateway, 1_000_000_000);
IGatewayZEVM(gateway).call(
receiver,
zrc20,
Expand Down
14 changes: 14 additions & 0 deletions universal/hello/tasks/callFromZetaChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
signer
);

const zrc20Artifact = await hre.artifacts.readArtifact("IZRC20");
const zrc20 = new hre.ethers.Contract(
args.zrc20,
zrc20Artifact.abi,
signer
);

const message = hre.ethers.utils.defaultAbiCoder.encode(
["string"],
[args.message]
Expand All @@ -20,6 +27,13 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const revertMessageBytes = hre.ethers.utils.toUtf8Bytes(args.revertMessage);

try {
const zrc20TransferTx = await zrc20.transfer(args.contract, 500_000_000,
{
gasPrice: 10000000000,
gasLimit: 7000000,
});
await zrc20TransferTx.wait();

const tx = await contract.callFromZetaChain(
hre.ethers.utils.hexlify(args.receiver),
args.zrc20,
Expand Down

0 comments on commit 325de30

Please sign in to comment.