// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/BaseOFTV2.sol"; /* Chain Information: LayerZero Optimism Goerli chainId: 10132 endpoint: 0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1 LayerZero Goerli chainId: 10121 endpoint: 0xbfD2135BFfbb0B5378b56643c2Df8a87552Bfa23 */ /* Example Tuple 1: Error https://goerli.etherscan.io/tx/0x92047bdd908d6241ef65fd21164855267e30a11460fa6cb0d8f485810d6a7931 Tuple Format ["srcRefundAddress", "ZROGasAddress", "_adaptParams bytes array"] ["0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486","0x0000000000000000000000000000000000000000","0x00010000000000000000000000000000000000000000000000000000000000030d40"] ["0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486","0x0000000000000000000000000000000000000000","0x00010000000000000000000000000000000000000000000000000000000000030d40"] ["0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486","0x0000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000000000000000000000000"] 32byte address: 0x0000000000000000000000009eb404fa6a9ad4bf45f20be8f07a16c491629486 Steps so far. 1. Deploy your ERC-20 on Georli 2. Deploy your ProxyOFT contract using your ERC-20 address, and specify the shared decimals (ie. where your ERC-20 decimals > shared-decimals). 3. Deploy your OFT contract and specify the shared decimals in relation to your ERC-20 & ProxyOFT. 4. Set your contracts to trust one another using setTrustedRemoteAddress. Pair them to one another's chain and address. 5. Next set your adapter parameters. I recommend setting this to 0, as it will use default gas settings. 6. Next we're going to set our minimum Gas Limit for each chain. Input into setMinDstGas the chainId of the other chain, the packet type ("0" meaning send, "1" meaning send and call). Make sure that your AdapterParams gas limit > setMinDstGas Note: If providedGasLimit >= minGasLimit, Fail: "LZApp: gas limit is too low", where providedGasLimit is _getGasLimit(_adapterParams) and minGasLimit is minDstGasLimit 7. Make sure adapter parameters are default, where the msg.value is equal to 55555555555 Wei when sending the transaction. ["0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486","0x0000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000000000000000000000000"] */ contract OFTV2 is BaseOFTV2, ERC20 { uint internal immutable ld2sdRate; constructor(string memory _name, string memory _symbol, uint8 _sharedDecimals, address _lzEndpoint) ERC20(_name, _symbol) BaseOFTV2(_sharedDecimals, _lzEndpoint) { uint8 decimals = decimals(); require(_sharedDecimals <= decimals, "OFT: sharedDecimals must be <= decimals"); ld2sdRate = 10 ** (decimals - _sharedDecimals); } /************************************************************************ * public functions ************************************************************************/ function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function token() public view virtual override returns (address) { return address(this); } /************************************************************************ * internal functions ************************************************************************/ function _debitFrom(address _from, uint16, bytes32, uint _amount) internal virtual override returns (uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns (uint) { _mint(_toAddress, _amount); return _amount; } function _transferFrom(address _from, address _to, uint _amount) internal virtual override returns (uint) { address spender = _msgSender(); // if transfer from this contract, no need to check allowance if (_from != address(this) && _from != spender) _spendAllowance(_from, spender, _amount); _transfer(_from, _to, _amount); return _amount; } function _ld2sdRate() internal view virtual override returns (uint) { return ld2sdRate; } }
0.4.18