fakeSender.sol 1.1 KB

123456789101112131415161718192021222324252627
  1. // SPDX-License-Identifier: UNLICENSED
  2. pragma solidity ^0.8.0;
  3. import "@layerzerolabs/solidity-examples/contracts/lzApp/interfaces/ILayerZeroEndpoint.sol";
  4. contract fakeSender {
  5. ILayerZeroEndpoint public endpoint;
  6. constructor(address _endpoint) {
  7. endpoint = ILayerZeroEndpoint(_endpoint);
  8. }
  9. // an endpoint is the contract which has the send() function
  10. function send(address _remoteAddress,address _localAddress, uint16 _dstChainId) external payable {
  11. // remote address concated with local address packed into 40 bytes
  12. bytes memory remoteAndLocalAddresses = abi.encodePacked(_remoteAddress, _localAddress);
  13. // call send() to send a message/payload to another chain
  14. endpoint.send{value: msg.value}(
  15. _dstChainId, // destination LayerZero chainId
  16. remoteAndLocalAddresses, // send to this address on the destination
  17. bytes("hello"), // bytes payload
  18. payable(msg.sender), // refund address
  19. address(0x0), // future parameter
  20. bytes("") // adapterParams (see "Advanced Features")
  21. );
  22. }
  23. }