-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Worker script | ||
|
||
To start local hardhat node execute: | ||
|
||
``` | ||
yarn localnode | ||
``` | ||
|
||
To start localnet using local hardhat: | ||
``` | ||
yarn localnet | ||
``` | ||
This will run worker script, which will deploy all contracts, and listen and react to events, facilitating communication between contracts. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { task } from "hardhat/config"; | ||
|
||
declare const hre: any; | ||
|
||
// Contains tasks to make it easier to interact with prototype contracts localnet | ||
// To make use of default contract addresses on localnet, start localnode and localnet from scratch, so contracts are deployed on same addresses | ||
// Otherwise, provide custom addresses as parameters | ||
|
||
task("call-evm-receiver", "calls evm receiver from zevm account") | ||
.addOptionalParam("gatewayZEVM", "contract address of gateway on ZEVM", "0x5133BBdfCCa3Eb4F739D599ee4eC45cBCD0E16c5") | ||
.addOptionalParam("receiverEVM", "contract address of receiver on EVM", "0xB06c856C8eaBd1d8321b687E188204C1018BC4E5") | ||
.setAction(async (taskArgs) => { | ||
const gatewayZEVM = await hre.ethers.getContractAt("GatewayZEVM", taskArgs.gatewayZEVM); | ||
const receiverEVM = await hre.ethers.getContractAt("ReceiverEVM", taskArgs.receiverEVM); | ||
|
||
const str = "Hello!"; | ||
const num = 42; | ||
const flag = true; | ||
|
||
// Encode the function call data and call on zevm | ||
const message = receiverEVM.interface.encodeFunctionData("receiveA", [str, num, flag]); | ||
const callTx = await gatewayZEVM.call(hre.ethers.utils.arrayify(receiverEVM.address), message); | ||
|
||
await callTx.wait(); | ||
console.log("ReceiverEVM called from ZEVM"); | ||
}); |