hel 1 年之前
父節點
當前提交
d403b5ebfd
共有 2 個文件被更改,包括 81 次插入0 次删除
  1. 27 0
      contracts/fakeSender.sol
  2. 54 0
      hardhat.config.js

+ 27 - 0
contracts/fakeSender.sol

@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: UNLICENSED
+pragma solidity ^0.8.0;
+
+import "@layerzerolabs/solidity-examples/contracts/lzApp/interfaces/ILayerZeroEndpoint.sol";
+
+contract fakeSender {
+  ILayerZeroEndpoint public endpoint;
+
+  constructor(address _endpoint) {
+    endpoint = ILayerZeroEndpoint(_endpoint);
+  }
+// an endpoint is the contract which has the send() function
+  function send(address _remoteAddress,address _localAddress, uint16 _dstChainId) external payable {
+// remote address concated with local address packed into 40 bytes
+    bytes memory remoteAndLocalAddresses = abi.encodePacked(_remoteAddress, _localAddress);
+// call send() to send a message/payload to another chain
+    endpoint.send{value: msg.value}(
+      _dstChainId,                   // destination LayerZero chainId
+      remoteAndLocalAddresses, // send to this address on the destination
+      bytes("hello"),          // bytes payload
+      payable(msg.sender),              // refund address
+      address(0x0),            // future parameter
+      bytes("")                // adapterParams (see "Advanced Features")
+    );
+  }
+
+}

+ 54 - 0
hardhat.config.js

@@ -0,0 +1,54 @@
+/** @type import('hardhat/config').HardhatUserConfig */
+module.exports = {
+  solidity: {
+    compilers: [
+      {
+        version: '0.8.0',
+        settings: {
+          'optimizer': {
+            'enabled': true,
+            'runs': 200
+          },
+          'outputSelection': {
+            '*': {
+              '*': [
+                'evm.bytecode',
+                'evm.deployedBytecode',
+                'abi'
+              ]
+            }
+          },
+          'metadata': {
+            'useLiteralContent': true
+          },
+          'libraries': {}
+        }
+      },
+      {
+        version: '0.6.12',
+        settings: {
+          'optimizer': {
+            'enabled': true,
+            'runs': 200
+          },
+          'outputSelection': {
+            '*': {
+              '*': [
+                'evm.bytecode',
+                'evm.deployedBytecode',
+                'abi'
+              ]
+            }
+          },
+          'metadata': {
+            'useLiteralContent': true
+          },
+          'libraries': {}
+        },
+      },
+      {version: '0.8.7'},
+      {version: '0.4.21'},
+      {version: '0.7.6'}],
+  },
+
+};