Contracts
Last updated
Last updated
Returns the Contract Application Binary Interface ( ABI ) of a verified smart contract.
Find verified contracts on our Verified Contracts Source Code page.
https://api.lineascan.build/api
?module=contract
&action=getabi
&address=0xba49765b67ba05070027297e8c6240ab7d1d10fb
&apikey=YourApiKeyToken
Try this endpoint in your browser
Query Parameters
Parameter | Description |
---|---|
Sample Response
{
"status": "1",
"message": "OK",
"result": "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_baseTokenURI\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_minGasToStore\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_layerZeroEndpoint\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_startMintId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_endMintId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_hashedPayload\",\"type\":\"bytes32\"}],\"name\":\"CreditCleared\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_hashedPayload\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"CreditStored\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_reason\",\"type\":\"bytes\"}],\"name\":\"MessageFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"indexed\":true,\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_toAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"ReceiveFromChain\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_payloadHash\",\"type\":\"bytes32\"}],\"name\":\"RetryMessageSuccess\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"SendToChain\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_dstChainIdToBatchLimit\",\"type\":\"uint256\"}],\"name\":\"SetDstChainIdToBatchLimit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_dstChainIdToTransferGas\",\"type\":\"uint256\"}],\"name\":\"SetDstChainIdToTransferGas\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_type\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_minDstGas\",\"type\":\"uint256\"}],\"name\":\"SetMinDstGas\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_minGasToTransferAndStore\",\"type\":\"uint256\"}],\"name\":\"SetMinGasToTransferAndStore\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"precrime\",\"type\":\"address\"}],\"name\":\"SetPrecrime\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_path\",\"type\":\"bytes\"}],\"name\":\"SetTrustedRemote\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_remoteAddress\",\"type\":\"bytes\"}],\"name\":\"SetTrustedRemoteAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_PAYLOAD_SIZE_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"FUNCTION_TYPE_SEND\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"baseTokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"clearCredits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cost\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"dstChainIdToBatchLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"dstChainIdToTransferGas\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"_useZro\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"estimateSendBatchFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nativeFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"zroFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_useZro\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"estimateSendFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nativeFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"zroFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"name\":\"failedMessages\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"}],\"name\":\"forceResumeReceive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"_chainId\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_configType\",\"type\":\"uint256\"}],\"name\":\"getConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"}],\"name\":\"getTrustedRemoteAddress\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"}],\"name\":\"isTrustedRemote\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lzEndpoint\",\"outputs\":[{\"internalType\":\"contract ILayerZeroEndpoint\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"lzReceive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxMintId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"minDstGasLookup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minGasToTransferAndStore\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextMintId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"nonblockingLzReceive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"payloadSizeLimitLookup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precrime\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"retryMessage\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"address payable\",\"name\":\"_refundAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_zroPaymentAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"sendBatchFrom\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address payable\",\"name\":\"_refundAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_zroPaymentAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"sendFrom\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_baseTokenURI\",\"type\":\"string\"}],\"name\":\"setBaseURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"_chainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_configType\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_config\",\"type\":\"bytes\"}],\"name\":\"setConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_dstChainIdToBatchLimit\",\"type\":\"uint256\"}],\"name\":\"setDstChainIdToBatchLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_dstChainIdToTransferGas\",\"type\":\"uint256\"}],\"name\":\"setDstChainIdToTransferGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"_packetType\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_minGas\",\"type\":\"uint256\"}],\"name\":\"setMinDstGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minGasToTransferAndStore\",\"type\":\"uint256\"}],\"name\":\"setMinGasToTransferAndStore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_size\",\"type\":\"uint256\"}],\"name\":\"setPayloadSizeLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_precrime\",\"type\":\"address\"}],\"name\":\"setPrecrime\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"}],\"name\":\"setReceiveVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"}],\"name\":\"setSendVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_path\",\"type\":\"bytes\"}],\"name\":\"setTrustedRemote\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_remoteAddress\",\"type\":\"bytes\"}],\"name\":\"setTrustedRemoteAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"storedCredits\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"toAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"creditsRemain\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_nftId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"trustedRemoteLookup\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}]"
}
A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract.
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider());
var version = web3.version.api;
$.getJSON('https://api.lineascan.build/api?module=contract&action=getabi&address=0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359', function (data) {
var contractABI = "";
contractABI = JSON.parse(data.result);
if (contractABI != ''){
var MyContract = web3.eth.contract(contractABI);
var myContractInstance = MyContract.at("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359");
var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715");
console.log("result1 : " + result);
var result = myContractInstance.members(1);
console.log("result2 : " + result);
} else {
console.log("Error" );
}
});
Returns the Solidity source code of a verified smart contract.
https://api.lineascan.build/api
?module=contract
&action=getsourcecode
&address=0xba49765b67ba05070027297e8c6240ab7d1d10fb
&apikey=YourApiKeyToken
Query Parameters
Sample Response
{
"status": "1",
"message": "OK",
"result": [
{
"SourceCode": "//SPDX-License-Identifier: MIT\r\n\r\n// File: @openzeppelin/contracts/utils/math/SignedMath.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Standard signed math utilities missing in the Solidity language.\r\n */\r\nlibrary SignedMath {\r\n /**\r\n * @dev Returns the largest of two signed numbers.\r\n */\r\n function max(int256 a, int256 b) internal pure returns (int256) {\r\n return a > b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the smallest of two signed numbers.\r\n */\r\n function min(int256 a, int256 b) internal pure returns (int256) {\r\n return a < b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the average of two signed numbers without overflow.\r\n * The result is rounded towards zero.\r\n */\r\n function average(int256 a, int256 b) internal pure returns (int256) {\r\n // Formula from the book \"Hacker's Delight\"\r\n int256 x = (a & b) + ((a ^ b) >> 1);\r\n return x + (int256(uint256(x) >> 255) & (a ^ b));\r\n }\r\n\r\n /**\r\n * @dev Returns the absolute unsigned value of a signed value.\r\n */\r\n function abs(int256 n) internal pure returns (uint256) {\r\n unchecked {\r\n // must be unchecked in order to support `n = type(int256).min`\r\n return uint256(n >= 0 ? n : -n);\r\n }\r\n }\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/math/Math.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Standard math utilities missing in the Solidity language.\r\n */\r\nlibrary Math {\r\n enum Rounding {\r\n Down, // Toward negative infinity\r\n Up, // Toward infinity\r\n Zero // Toward zero\r\n }\r\n\r\n /**\r\n * @dev Returns the largest of two numbers.\r\n */\r\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a > b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the smallest of two numbers.\r\n */\r\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a < b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the average of two numbers. The result is rounded towards\r\n * zero.\r\n */\r\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // (a + b) / 2 can overflow.\r\n return (a & b) + (a ^ b) / 2;\r\n }\r\n\r\n /**\r\n * @dev Returns the ceiling of the division of two numbers.\r\n *\r\n * This differs from standard division with `/` in that it rounds up instead\r\n * of rounding down.\r\n */\r\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // (a + b - 1) / b can overflow on addition, so we distribute.\r\n return a == 0 ? 0 : (a - 1) / b + 1;\r\n }\r\n\r\n /**\r\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\r\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\r\n * with further edits by Uniswap Labs also under MIT license.\r\n */\r\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\r\n unchecked {\r\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\r\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\r\n // variables such that product = prod1 * 2^256 + prod0.\r\n uint256 prod0; // Least significant 256 bits of the product\r\n uint256 prod1; // Most significant 256 bits of the product\r\n assembly {\r\n let mm := mulmod(x, y, not(0))\r\n prod0 := mul(x, y)\r\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\r\n }\r\n\r\n // Handle non-overflow cases, 256 by 256 division.\r\n if (prod1 == 0) {\r\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\r\n // The surrounding unchecked block does not change this fact.\r\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\r\n return prod0 / denominator;\r\n }\r\n\r\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\r\n require(denominator > prod1, \"Math: mulDiv overflow\");\r\n\r\n ///////////////////////////////////////////////\r\n // 512 by 256 division.\r\n ///////////////////////////////////////////////\r\n\r\n // Make division exact by subtracting the remainder from [prod1 prod0].\r\n uint256 remainder;\r\n assembly {\r\n // Compute remainder using mulmod.\r\n remainder := mulmod(x, y, denominator)\r\n\r\n // Subtract 256 bit number from 512 bit number.\r\n prod1 := sub(prod1, gt(remainder, prod0))\r\n prod0 := sub(prod0, remainder)\r\n }\r\n\r\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\r\n // See https://cs.stackexchange.com/q/138556/92363.\r\n\r\n // Does not overflow because the denominator cannot be zero at this stage in the function.\r\n uint256 twos = denominator & (~denominator + 1);\r\n assembly {\r\n // Divide denominator by twos.\r\n denominator := div(denominator, twos)\r\n\r\n // Divide [prod1 prod0] by twos.\r\n prod0 := div(prod0, twos)\r\n\r\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\r\n twos := add(div(sub(0, twos), twos), 1)\r\n }\r\n\r\n // Shift in bits from prod1 into prod0.\r\n prod0 |= prod1 * twos;\r\n\r\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\r\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\r\n // four bits. That is, denominator * inv = 1 mod 2^4.\r\n uint256 inverse = (3 * denominator) ^ 2;\r\n\r\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\r\n // in modular arithmetic, doubling the correct bits in each step.\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\r\n\r\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\r\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\r\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\r\n // is no longer required.\r\n result = prod0 * inverse;\r\n return result;\r\n }\r\n }\r\n\r\n /**\r\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\r\n */\r\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\r\n uint256 result = mulDiv(x, y, denominator);\r\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\r\n result += 1;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\r\n *\r\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\r\n */\r\n function sqrt(uint256 a) internal pure returns (uint256) {\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\r\n //\r\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\r\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\r\n //\r\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\r\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\r\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\r\n //\r\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\r\n uint256 result = 1 << (log2(a) >> 1);\r\n\r\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\r\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\r\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\r\n // into the expected uint128 result.\r\n unchecked {\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n return min(result, a / result);\r\n }\r\n }\r\n\r\n /**\r\n * @notice Calculates sqrt(a), following the selected rounding direction.\r\n */\r\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = sqrt(a);\r\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 2, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log2(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value >> 128 > 0) {\r\n value >>= 128;\r\n result += 128;\r\n }\r\n if (value >> 64 > 0) {\r\n value >>= 64;\r\n result += 64;\r\n }\r\n if (value >> 32 > 0) {\r\n value >>= 32;\r\n result += 32;\r\n }\r\n if (value >> 16 > 0) {\r\n value >>= 16;\r\n result += 16;\r\n }\r\n if (value >> 8 > 0) {\r\n value >>= 8;\r\n result += 8;\r\n }\r\n if (value >> 4 > 0) {\r\n value >>= 4;\r\n result += 4;\r\n }\r\n if (value >> 2 > 0) {\r\n value >>= 2;\r\n result += 2;\r\n }\r\n if (value >> 1 > 0) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log2(value);\r\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log10(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value >= 10 ** 64) {\r\n value /= 10 ** 64;\r\n result += 64;\r\n }\r\n if (value >= 10 ** 32) {\r\n value /= 10 ** 32;\r\n result += 32;\r\n }\r\n if (value >= 10 ** 16) {\r\n value /= 10 ** 16;\r\n result += 16;\r\n }\r\n if (value >= 10 ** 8) {\r\n value /= 10 ** 8;\r\n result += 8;\r\n }\r\n if (value >= 10 ** 4) {\r\n value /= 10 ** 4;\r\n result += 4;\r\n }\r\n if (value >= 10 ** 2) {\r\n value /= 10 ** 2;\r\n result += 2;\r\n }\r\n if (value >= 10 ** 1) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log10(value);\r\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 256, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n *\r\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\r\n */\r\n function log256(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value >> 128 > 0) {\r\n value >>= 128;\r\n result += 16;\r\n }\r\n if (value >> 64 > 0) {\r\n value >>= 64;\r\n result += 8;\r\n }\r\n if (value >> 32 > 0) {\r\n value >>= 32;\r\n result += 4;\r\n }\r\n if (value >> 16 > 0) {\r\n value >>= 16;\r\n result += 2;\r\n }\r\n if (value >> 8 > 0) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log256(value);\r\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\r\n }\r\n }\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/Strings.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n\r\n/**\r\n * @dev String operations.\r\n */\r\nlibrary Strings {\r\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\r\n uint8 private constant _ADDRESS_LENGTH = 20;\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n unchecked {\r\n uint256 length = Math.log10(value) + 1;\r\n string memory buffer = new string(length);\r\n uint256 ptr;\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n ptr := add(buffer, add(32, length))\r\n }\r\n while (true) {\r\n ptr--;\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\r\n }\r\n value /= 10;\r\n if (value == 0) break;\r\n }\r\n return buffer;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(int256 value) internal pure returns (string memory) {\r\n return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(uint256 value) internal pure returns (string memory) {\r\n unchecked {\r\n return toHexString(value, Math.log256(value) + 1);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\r\n */\r\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\r\n bytes memory buffer = new bytes(2 * length + 2);\r\n buffer[0] = \"0\";\r\n buffer[1] = \"x\";\r\n for (uint256 i = 2 * length + 1; i > 1; --i) {\r\n buffer[i] = _SYMBOLS[value & 0xf];\r\n value >>= 4;\r\n }\r\n require(value == 0, \"Strings: hex length insufficient\");\r\n return string(buffer);\r\n }\r\n\r\n /**\r\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(address addr) internal pure returns (string memory) {\r\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\r\n }\r\n\r\n /**\r\n * @dev Returns true if the two strings are equal.\r\n */\r\n function equal(string memory a, string memory b) internal pure returns (bool) {\r\n return keccak256(bytes(a)) == keccak256(bytes(b));\r\n }\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/Address.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\r\n\r\npragma solidity ^0.8.1;\r\n\r\n/**\r\n * @dev Collection of functions related to the address type\r\n */\r\nlibrary Address {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n *\r\n * Furthermore, `isContract` will also return true if the target contract within\r\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\r\n * which only has an effect at the end of a transaction.\r\n * ====\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\r\n *\r\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\r\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\r\n * constructor.\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize/address.code.length, which returns 0\r\n // for contracts in construction, since the code is only stored at the end\r\n // of the constructor execution.\r\n\r\n return account.code.length > 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(address(this).balance >= amount, \"Address: insufficient balance\");\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(success, \"Address: unable to send value, recipient may have reverted\");\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\r\n (bool success, bytes memory returndata) = target.call{value: value}(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\r\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n (bool success, bytes memory returndata) = target.delegatecall(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\r\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\r\n *\r\n * _Available since v4.8._\r\n */\r\n function verifyCallResultFromTarget(\r\n address target,\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n if (success) {\r\n if (returndata.length == 0) {\r\n // only check isContract if the call was successful and the return data is empty\r\n // otherwise we already know that it was a contract\r\n require(isContract(target), \"Address: call to non-contract\");\r\n }\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\r\n * revert reason or using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length > 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n}\r\n\r\n// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @title ERC721 token receiver interface\r\n * @dev Interface for any contract that wants to support safeTransfers\r\n * from ERC721 asset contracts.\r\n */\r\ninterface IERC721Receiver {\r\n /**\r\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\r\n * by `operator` from `from`, this function is called.\r\n *\r\n * It must return its Solidity selector to confirm the token transfer.\r\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\r\n *\r\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\r\n */\r\n function onERC721Received(\r\n address operator,\r\n address from,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external returns (bytes4);\r\n}\r\n\r\n// File: @openzeppelin/contracts/security/ReentrancyGuard.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Contract module that helps prevent reentrant calls to a function.\r\n *\r\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\r\n * available, which can be applied to functions to make sure there are no nested\r\n * (reentrant) calls to them.\r\n *\r\n * Note that because there is a single `nonReentrant` guard, functions marked as\r\n * `nonReentrant` may not call one another. This can be worked around by making\r\n * those functions `private`, and then adding `external` `nonReentrant` entry\r\n * points to them.\r\n *\r\n * TIP: If you would like to learn more about reentrancy and alternative ways\r\n * to protect against it, check out our blog post\r\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\r\n */\r\nabstract contract ReentrancyGuard {\r\n // Booleans are more expensive than uint256 or any type that takes up a full\r\n // word because each write operation emits an extra SLOAD to first read the\r\n // slot's contents, replace the bits taken up by the boolean, and then write\r\n // back. This is the compiler's defense against contract upgrades and\r\n // pointer aliasing, and it cannot be disabled.\r\n\r\n // The values being non-zero value makes deployment a bit more expensive,\r\n // but in exchange the refund on every call to nonReentrant will be lower in\r\n // amount. Since refunds are capped to a percentage of the total\r\n // transaction's gas, it is best to keep them low in cases like this one, to\r\n // increase the likelihood of the full refund coming into effect.\r\n uint256 private constant _NOT_ENTERED = 1;\r\n uint256 private constant _ENTERED = 2;\r\n\r\n uint256 private _status;\r\n\r\n constructor() {\r\n _status = _NOT_ENTERED;\r\n }\r\n\r\n /**\r\n * @dev Prevents a contract from calling itself, directly or indirectly.\r\n * Calling a `nonReentrant` function from another `nonReentrant`\r\n * function is not supported. It is possible to prevent this from happening\r\n * by making the `nonReentrant` function external, and making it call a\r\n * `private` function that does the actual work.\r\n */\r\n modifier nonReentrant() {\r\n _nonReentrantBefore();\r\n _;\r\n _nonReentrantAfter();\r\n }\r\n\r\n function _nonReentrantBefore() private {\r\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\r\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\r\n\r\n // Any calls to nonReentrant after this point will fail\r\n _status = _ENTERED;\r\n }\r\n\r\n function _nonReentrantAfter() private {\r\n // By storing the original value once again, a refund is triggered (see\r\n // https://eips.ethereum.org/EIPS/eip-2200)\r\n _status = _NOT_ENTERED;\r\n }\r\n\r\n /**\r\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\r\n * `nonReentrant` function in the call stack.\r\n */\r\n function _reentrancyGuardEntered() internal view returns (bool) {\r\n return _status == _ENTERED;\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/util/ExcessivelySafeCall.sol\r\n\r\n\r\npragma solidity >=0.7.6;\r\n\r\nlibrary ExcessivelySafeCall {\r\n uint256 constant LOW_28_MASK =\r\n 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\r\n\r\n /// @notice Use when you _really_ really _really_ don't trust the called\r\n /// contract. This prevents the called contract from causing reversion of\r\n /// the caller in as many ways as we can.\r\n /// @dev The main difference between this and a solidity low-level call is\r\n /// that we limit the number of bytes that the callee can cause to be\r\n /// copied to caller memory. This prevents stupid things like malicious\r\n /// contracts returning 10,000,000 bytes causing a local OOG when copying\r\n /// to memory.\r\n /// @param _target The address to call\r\n /// @param _gas The amount of gas to forward to the remote contract\r\n /// @param _maxCopy The maximum number of bytes of returndata to copy\r\n /// to memory.\r\n /// @param _calldata The data to send to the remote contract\r\n /// @return success and returndata, as `.call()`. Returndata is capped to\r\n /// `_maxCopy` bytes.\r\n function excessivelySafeCall(\r\n address _target,\r\n uint256 _gas,\r\n uint16 _maxCopy,\r\n bytes memory _calldata\r\n ) internal returns (bool, bytes memory) {\r\n // set up for assembly call\r\n uint256 _toCopy;\r\n bool _success;\r\n bytes memory _returnData = new bytes(_maxCopy);\r\n // dispatch message to recipient\r\n // by assembly calling \"handle\" function\r\n // we call via assembly to avoid memcopying a very large returndata\r\n // returned by a malicious contract\r\n assembly {\r\n _success := call(\r\n _gas, // gas\r\n _target, // recipient\r\n 0, // ether value\r\n add(_calldata, 0x20), // inloc\r\n mload(_calldata), // inlen\r\n 0, // outloc\r\n 0 // outlen\r\n )\r\n // limit our copy to 256 bytes\r\n _toCopy := returndatasize()\r\n if gt(_toCopy, _maxCopy) {\r\n _toCopy := _maxCopy\r\n }\r\n // Store the length of the copied bytes\r\n mstore(_returnData, _toCopy)\r\n // copy the bytes from returndata[0:_toCopy]\r\n returndatacopy(add(_returnData, 0x20), 0, _toCopy)\r\n }\r\n return (_success, _returnData);\r\n }\r\n\r\n /// @notice Use when you _really_ really _really_ don't trust the called\r\n /// contract. This prevents the called contract from causing reversion of\r\n /// the caller in as many ways as we can.\r\n /// @dev The main difference between this and a solidity low-level call is\r\n /// that we limit the number of bytes that the callee can cause to be\r\n /// copied to caller memory. This prevents stupid things like malicious\r\n /// contracts returning 10,000,000 bytes causing a local OOG when copying\r\n /// to memory.\r\n /// @param _target The address to call\r\n /// @param _gas The amount of gas to forward to the remote contract\r\n /// @param _maxCopy The maximum number of bytes of returndata to copy\r\n /// to memory.\r\n /// @param _calldata The data to send to the remote contract\r\n /// @return success and returndata, as `.call()`. Returndata is capped to\r\n /// `_maxCopy` bytes.\r\n function excessivelySafeStaticCall(\r\n address _target,\r\n uint256 _gas,\r\n uint16 _maxCopy,\r\n bytes memory _calldata\r\n ) internal view returns (bool, bytes memory) {\r\n // set up for assembly call\r\n uint256 _toCopy;\r\n bool _success;\r\n bytes memory _returnData = new bytes(_maxCopy);\r\n // dispatch message to recipient\r\n // by assembly calling \"handle\" function\r\n // we call via assembly to avoid memcopying a very large returndata\r\n // returned by a malicious contract\r\n assembly {\r\n _success := staticcall(\r\n _gas, // gas\r\n _target, // recipient\r\n add(_calldata, 0x20), // inloc\r\n mload(_calldata), // inlen\r\n 0, // outloc\r\n 0 // outlen\r\n )\r\n // limit our copy to 256 bytes\r\n _toCopy := returndatasize()\r\n if gt(_toCopy, _maxCopy) {\r\n _toCopy := _maxCopy\r\n }\r\n // Store the length of the copied bytes\r\n mstore(_returnData, _toCopy)\r\n // copy the bytes from returndata[0:_toCopy]\r\n returndatacopy(add(_returnData, 0x20), 0, _toCopy)\r\n }\r\n return (_success, _returnData);\r\n }\r\n\r\n /**\r\n * @notice Swaps function selectors in encoded contract calls\r\n * @dev Allows reuse of encoded calldata for functions with identical\r\n * argument types but different names. It simply swaps out the first 4 bytes\r\n * for the new selector. This function modifies memory in place, and should\r\n * only be used with caution.\r\n * @param _newSelector The new 4-byte selector\r\n * @param _buf The encoded contract args\r\n */\r\n function swapSelector(bytes4 _newSelector, bytes memory _buf)\r\n internal\r\n pure\r\n {\r\n require(_buf.length >= 4);\r\n uint256 _mask = LOW_28_MASK;\r\n assembly {\r\n // load the first word of\r\n let _word := mload(add(_buf, 0x20))\r\n // mask out the top 4 bytes\r\n // /x\r\n _word := and(_word, _mask)\r\n _word := or(_newSelector, _word)\r\n mstore(add(_buf, 0x20), _word)\r\n }\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/util/BytesLib.sol\r\n\r\n\r\n/*\r\n * @title Solidity Bytes Arrays Utils\r\n * @author Gonçalo Sá <goncalo.sa@consensys.net>\r\n *\r\n * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.\r\n * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.\r\n */\r\npragma solidity >=0.8.0 <0.9.0;\r\n\r\n\r\nlibrary BytesLib {\r\n function concat(\r\n bytes memory _preBytes,\r\n bytes memory _postBytes\r\n )\r\n internal\r\n pure\r\n returns (bytes memory)\r\n {\r\n bytes memory tempBytes;\r\n\r\n assembly {\r\n // Get a location of some free memory and store it in tempBytes as\r\n // Solidity does for memory variables.\r\n tempBytes := mload(0x40)\r\n\r\n // Store the length of the first bytes array at the beginning of\r\n // the memory for tempBytes.\r\n let length := mload(_preBytes)\r\n mstore(tempBytes, length)\r\n\r\n // Maintain a memory counter for the current write location in the\r\n // temp bytes array by adding the 32 bytes for the array length to\r\n // the starting location.\r\n let mc := add(tempBytes, 0x20)\r\n // Stop copying when the memory counter reaches the length of the\r\n // first bytes array.\r\n let end := add(mc, length)\r\n\r\n for {\r\n // Initialize a copy counter to the start of the _preBytes data,\r\n // 32 bytes into its memory.\r\n let cc := add(_preBytes, 0x20)\r\n } lt(mc, end) {\r\n // Increase both counters by 32 bytes each iteration.\r\n mc := add(mc, 0x20)\r\n cc := add(cc, 0x20)\r\n } {\r\n // Write the _preBytes data into the tempBytes memory 32 bytes\r\n // at a time.\r\n mstore(mc, mload(cc))\r\n }\r\n\r\n // Add the length of _postBytes to the current length of tempBytes\r\n // and store it as the new length in the first 32 bytes of the\r\n // tempBytes memory.\r\n length := mload(_postBytes)\r\n mstore(tempBytes, add(length, mload(tempBytes)))\r\n\r\n // Move the memory counter back from a multiple of 0x20 to the\r\n // actual end of the _preBytes data.\r\n mc := end\r\n // Stop copying when the memory counter reaches the new combined\r\n // length of the arrays.\r\n end := add(mc, length)\r\n\r\n for {\r\n let cc := add(_postBytes, 0x20)\r\n } lt(mc, end) {\r\n mc := add(mc, 0x20)\r\n cc := add(cc, 0x20)\r\n } {\r\n mstore(mc, mload(cc))\r\n }\r\n\r\n // Update the free-memory pointer by padding our last write location\r\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\r\n // next 32 byte block, then round down to the nearest multiple of\r\n // 32. If the sum of the length of the two arrays is zero then add\r\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\r\n mstore(0x40, and(\r\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\r\n not(31) // Round down to the nearest 32 bytes.\r\n ))\r\n }\r\n\r\n return tempBytes;\r\n }\r\n\r\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\r\n assembly {\r\n // Read the first 32 bytes of _preBytes storage, which is the length\r\n // of the array. (We don't need to use the offset into the slot\r\n // because arrays use the entire slot.)\r\n let fslot := sload(_preBytes.slot)\r\n // Arrays of 31 bytes or less have an even value in their slot,\r\n // while longer arrays have an odd value. The actual length is\r\n // the slot divided by two for odd values, and the lowest order\r\n // byte divided by two for even values.\r\n // If the slot is even, bitwise and the slot with 255 and divide by\r\n // two to get the length. If the slot is odd, bitwise and the slot\r\n // with -1 and divide by two.\r\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\r\n let mlength := mload(_postBytes)\r\n let newlength := add(slength, mlength)\r\n // slength can contain both the length and contents of the array\r\n // if length < 32 bytes so let's prepare for that\r\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\r\n switch add(lt(slength, 32), lt(newlength, 32))\r\n case 2 {\r\n // Since the new array still fits in the slot, we just need to\r\n // update the contents of the slot.\r\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\r\n sstore(\r\n _preBytes.slot,\r\n // all the modifications to the slot are inside this\r\n // next block\r\n add(\r\n // we can just add to the slot contents because the\r\n // bytes we want to change are the LSBs\r\n fslot,\r\n add(\r\n mul(\r\n div(\r\n // load the bytes from memory\r\n mload(add(_postBytes, 0x20)),\r\n // zero all bytes to the right\r\n exp(0x100, sub(32, mlength))\r\n ),\r\n // and now shift left the number of bytes to\r\n // leave space for the length in the slot\r\n exp(0x100, sub(32, newlength))\r\n ),\r\n // increase length by the double of the memory\r\n // bytes length\r\n mul(mlength, 2)\r\n )\r\n )\r\n )\r\n }\r\n case 1 {\r\n // The stored value fits in the slot, but the combined value\r\n // will exceed it.\r\n // get the keccak hash to get the contents of the array\r\n mstore(0x0, _preBytes.slot)\r\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\r\n\r\n // save new length\r\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\r\n\r\n // The contents of the _postBytes array start 32 bytes into\r\n // the structure. Our first read should obtain the `submod`\r\n // bytes that can fit into the unused space in the last word\r\n // of the stored array. To get this, we read 32 bytes starting\r\n // from `submod`, so the data we read overlaps with the array\r\n // contents by `submod` bytes. Masking the lowest-order\r\n // `submod` bytes allows us to add that value directly to the\r\n // stored value.\r\n\r\n let submod := sub(32, slength)\r\n let mc := add(_postBytes, submod)\r\n let end := add(_postBytes, mlength)\r\n let mask := sub(exp(0x100, submod), 1)\r\n\r\n sstore(\r\n sc,\r\n add(\r\n and(\r\n fslot,\r\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\r\n ),\r\n and(mload(mc), mask)\r\n )\r\n )\r\n\r\n for {\r\n mc := add(mc, 0x20)\r\n sc := add(sc, 1)\r\n } lt(mc, end) {\r\n sc := add(sc, 1)\r\n mc := add(mc, 0x20)\r\n } {\r\n sstore(sc, mload(mc))\r\n }\r\n\r\n mask := exp(0x100, sub(mc, end))\r\n\r\n sstore(sc, mul(div(mload(mc), mask), mask))\r\n }\r\n default {\r\n // get the keccak hash to get the contents of the array\r\n mstore(0x0, _preBytes.slot)\r\n // Start copying to the last used word of the stored array.\r\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\r\n\r\n // save new length\r\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\r\n\r\n // Copy over the first `submod` bytes of the new data as in\r\n // case 1 above.\r\n let slengthmod := mod(slength, 32)\r\n let mlengthmod := mod(mlength, 32)\r\n let submod := sub(32, slengthmod)\r\n let mc := add(_postBytes, submod)\r\n let end := add(_postBytes, mlength)\r\n let mask := sub(exp(0x100, submod), 1)\r\n\r\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\r\n\r\n for {\r\n sc := add(sc, 1)\r\n mc := add(mc, 0x20)\r\n } lt(mc, end) {\r\n sc := add(sc, 1)\r\n mc := add(mc, 0x20)\r\n } {\r\n sstore(sc, mload(mc))\r\n }\r\n\r\n mask := exp(0x100, sub(mc, end))\r\n\r\n sstore(sc, mul(div(mload(mc), mask), mask))\r\n }\r\n }\r\n }\r\n\r\n function slice(\r\n bytes memory _bytes,\r\n uint256 _start,\r\n uint256 _length\r\n )\r\n internal\r\n pure\r\n returns (bytes memory)\r\n {\r\n require(_length + 31 >= _length, \"slice_overflow\");\r\n require(_bytes.length >= _start + _length, \"slice_outOfBounds\");\r\n\r\n bytes memory tempBytes;\r\n\r\n assembly {\r\n switch iszero(_length)\r\n case 0 {\r\n // Get a location of some free memory and store it in tempBytes as\r\n // Solidity does for memory variables.\r\n tempBytes := mload(0x40)\r\n\r\n // The first word of the slice result is potentially a partial\r\n // word read from the original array. To read it, we calculate\r\n // the length of that partial word and start copying that many\r\n // bytes into the array. The first word we copy will start with\r\n // data we don't care about, but the last `lengthmod` bytes will\r\n // land at the beginning of the contents of the new array. When\r\n // we're done copying, we overwrite the full first word with\r\n // the actual length of the slice.\r\n let lengthmod := and(_length, 31)\r\n\r\n // The multiplication in the next line is necessary\r\n // because when slicing multiples of 32 bytes (lengthmod == 0)\r\n // the following copy loop was copying the origin's length\r\n // and then ending prematurely not copying everything it should.\r\n let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))\r\n let end := add(mc, _length)\r\n\r\n for {\r\n // The multiplication in the next line has the same exact purpose\r\n // as the one above.\r\n let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)\r\n } lt(mc, end) {\r\n mc := add(mc, 0x20)\r\n cc := add(cc, 0x20)\r\n } {\r\n mstore(mc, mload(cc))\r\n }\r\n\r\n mstore(tempBytes, _length)\r\n\r\n //update free-memory pointer\r\n //allocating the array padded to 32 bytes like the compiler does now\r\n mstore(0x40, and(add(mc, 31), not(31)))\r\n }\r\n //if we want a zero-length slice let's just return a zero-length array\r\n default {\r\n tempBytes := mload(0x40)\r\n //zero out the 32 bytes slice we are about to return\r\n //we need to do it because Solidity does not garbage collect\r\n mstore(tempBytes, 0)\r\n\r\n mstore(0x40, add(tempBytes, 0x20))\r\n }\r\n }\r\n\r\n return tempBytes;\r\n }\r\n\r\n function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {\r\n require(_bytes.length >= _start + 20, \"toAddress_outOfBounds\");\r\n address tempAddress;\r\n\r\n assembly {\r\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\r\n }\r\n\r\n return tempAddress;\r\n }\r\n\r\n function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {\r\n require(_bytes.length >= _start + 1 , \"toUint8_outOfBounds\");\r\n uint8 tempUint;\r\n\r\n assembly {\r\n tempUint := mload(add(add(_bytes, 0x1), _start))\r\n }\r\n\r\n return tempUint;\r\n }\r\n\r\n function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {\r\n require(_bytes.length >= _start + 2, \"toUint16_outOfBounds\");\r\n uint16 tempUint;\r\n\r\n assembly {\r\n tempUint := mload(add(add(_bytes, 0x2), _start))\r\n }\r\n\r\n return tempUint;\r\n }\r\n\r\n function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {\r\n require(_bytes.length >= _start + 4, \"toUint32_outOfBounds\");\r\n uint32 tempUint;\r\n\r\n assembly {\r\n tempUint := mload(add(add(_bytes, 0x4), _start))\r\n }\r\n\r\n return tempUint;\r\n }\r\n\r\n function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {\r\n require(_bytes.length >= _start + 8, \"toUint64_outOfBounds\");\r\n uint64 tempUint;\r\n\r\n assembly {\r\n tempUint := mload(add(add(_bytes, 0x8), _start))\r\n }\r\n\r\n return tempUint;\r\n }\r\n\r\n function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {\r\n require(_bytes.length >= _start + 12, \"toUint96_outOfBounds\");\r\n uint96 tempUint;\r\n\r\n assembly {\r\n tempUint := mload(add(add(_bytes, 0xc), _start))\r\n }\r\n\r\n return tempUint;\r\n }\r\n\r\n function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {\r\n require(_bytes.length >= _start + 16, \"toUint128_outOfBounds\");\r\n uint128 tempUint;\r\n\r\n assembly {\r\n tempUint := mload(add(add(_bytes, 0x10), _start))\r\n }\r\n\r\n return tempUint;\r\n }\r\n\r\n function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {\r\n require(_bytes.length >= _start + 32, \"toUint256_outOfBounds\");\r\n uint256 tempUint;\r\n\r\n assembly {\r\n tempUint := mload(add(add(_bytes, 0x20), _start))\r\n }\r\n\r\n return tempUint;\r\n }\r\n\r\n function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {\r\n require(_bytes.length >= _start + 32, \"toBytes32_outOfBounds\");\r\n bytes32 tempBytes32;\r\n\r\n assembly {\r\n tempBytes32 := mload(add(add(_bytes, 0x20), _start))\r\n }\r\n\r\n return tempBytes32;\r\n }\r\n\r\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\r\n bool success = true;\r\n\r\n assembly {\r\n let length := mload(_preBytes)\r\n\r\n // if lengths don't match the arrays are not equal\r\n switch eq(length, mload(_postBytes))\r\n case 1 {\r\n // cb is a circuit breaker in the for loop since there's\r\n // no said feature for inline assembly loops\r\n // cb = 1 - don't breaker\r\n // cb = 0 - break\r\n let cb := 1\r\n\r\n let mc := add(_preBytes, 0x20)\r\n let end := add(mc, length)\r\n\r\n for {\r\n let cc := add(_postBytes, 0x20)\r\n // the next line is the loop condition:\r\n // while(uint256(mc < end) + cb == 2)\r\n } eq(add(lt(mc, end), cb), 2) {\r\n mc := add(mc, 0x20)\r\n cc := add(cc, 0x20)\r\n } {\r\n // if any of these checks fails then arrays are not equal\r\n if iszero(eq(mload(mc), mload(cc))) {\r\n // unsuccess:\r\n success := 0\r\n cb := 0\r\n }\r\n }\r\n }\r\n default {\r\n // unsuccess:\r\n success := 0\r\n }\r\n }\r\n\r\n return success;\r\n }\r\n\r\n function equalStorage(\r\n bytes storage _preBytes,\r\n bytes memory _postBytes\r\n )\r\n internal\r\n view\r\n returns (bool)\r\n {\r\n bool success = true;\r\n\r\n assembly {\r\n // we know _preBytes_offset is 0\r\n let fslot := sload(_preBytes.slot)\r\n // Decode the length of the stored array like in concatStorage().\r\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\r\n let mlength := mload(_postBytes)\r\n\r\n // if lengths don't match the arrays are not equal\r\n switch eq(slength, mlength)\r\n case 1 {\r\n // slength can contain both the length and contents of the array\r\n // if length < 32 bytes so let's prepare for that\r\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\r\n if iszero(iszero(slength)) {\r\n switch lt(slength, 32)\r\n case 1 {\r\n // blank the last byte which is the length\r\n fslot := mul(div(fslot, 0x100), 0x100)\r\n\r\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\r\n // unsuccess:\r\n success := 0\r\n }\r\n }\r\n default {\r\n // cb is a circuit breaker in the for loop since there's\r\n // no said feature for inline assembly loops\r\n // cb = 1 - don't breaker\r\n // cb = 0 - break\r\n let cb := 1\r\n\r\n // get the keccak hash to get the contents of the array\r\n mstore(0x0, _preBytes.slot)\r\n let sc := keccak256(0x0, 0x20)\r\n\r\n let mc := add(_postBytes, 0x20)\r\n let end := add(mc, mlength)\r\n\r\n // the next line is the loop condition:\r\n // while(uint256(mc < end) + cb == 2)\r\n for {} eq(add(lt(mc, end), cb), 2) {\r\n sc := add(sc, 1)\r\n mc := add(mc, 0x20)\r\n } {\r\n if iszero(eq(sload(sc), mload(mc))) {\r\n // unsuccess:\r\n success := 0\r\n cb := 0\r\n }\r\n }\r\n }\r\n }\r\n }\r\n default {\r\n // unsuccess:\r\n success := 0\r\n }\r\n }\r\n\r\n return success;\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/interfaces/ILayerZeroUserApplicationConfig.sol\r\n\r\n\r\n\r\npragma solidity >=0.5.0;\r\n\r\ninterface ILayerZeroUserApplicationConfig {\r\n // @notice set the configuration of the LayerZero messaging library of the specified version\r\n // @param _version - messaging library version\r\n // @param _chainId - the chainId for the pending config change\r\n // @param _configType - type of configuration. every messaging library has its own convention.\r\n // @param _config - configuration in the bytes. can encode arbitrary content.\r\n function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;\r\n\r\n // @notice set the send() LayerZero messaging library version to _version\r\n // @param _version - new messaging library version\r\n function setSendVersion(uint16 _version) external;\r\n\r\n // @notice set the lzReceive() LayerZero messaging library version to _version\r\n // @param _version - new messaging library version\r\n function setReceiveVersion(uint16 _version) external;\r\n\r\n // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload\r\n // @param _srcChainId - the chainId of the source chain\r\n // @param _srcAddress - the contract address of the source contract at the source chain\r\n function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;\r\n}\r\n\r\n// File: contracts/lz-contracts/interfaces/ILayerZeroEndpoint.sol\r\n\r\n\r\n\r\npragma solidity >=0.5.0;\r\n\r\n\r\ninterface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {\r\n // @notice send a LayerZero message to the specified address at a LayerZero endpoint.\r\n // @param _dstChainId - the destination chain identifier\r\n // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains\r\n // @param _payload - a custom bytes payload to send to the destination contract\r\n // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address\r\n // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction\r\n // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination\r\n function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;\r\n\r\n // @notice used by the messaging library to publish verified payload\r\n // @param _srcChainId - the source chain identifier\r\n // @param _srcAddress - the source contract (as bytes) at the source chain\r\n // @param _dstAddress - the address on destination chain\r\n // @param _nonce - the unbound message ordering nonce\r\n // @param _gasLimit - the gas limit for external contract execution\r\n // @param _payload - verified payload to send to the destination contract\r\n function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external;\r\n\r\n // @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain\r\n // @param _srcChainId - the source chain identifier\r\n // @param _srcAddress - the source chain contract address\r\n function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);\r\n\r\n // @notice get the outboundNonce from this source chain which, consequently, is always an EVM\r\n // @param _srcAddress - the source chain contract address\r\n function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);\r\n\r\n // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery\r\n // @param _dstChainId - the destination chain identifier\r\n // @param _userApplication - the user app address on this EVM chain\r\n // @param _payload - the custom message to send over LayerZero\r\n // @param _payInZRO - if false, user app pays the protocol fee in native token\r\n // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain\r\n function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee);\r\n\r\n // @notice get this Endpoint's immutable source identifier\r\n function getChainId() external view returns (uint16);\r\n\r\n // @notice the interface to retry failed message on this Endpoint destination\r\n // @param _srcChainId - the source chain identifier\r\n // @param _srcAddress - the source chain contract address\r\n // @param _payload - the payload to be retried\r\n function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;\r\n\r\n // @notice query if any STORED payload (message blocking) at the endpoint.\r\n // @param _srcChainId - the source chain identifier\r\n // @param _srcAddress - the source chain contract address\r\n function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);\r\n\r\n // @notice query if the _libraryAddress is valid for sending msgs.\r\n // @param _userApplication - the user app address on this EVM chain\r\n function getSendLibraryAddress(address _userApplication) external view returns (address);\r\n\r\n // @notice query if the _libraryAddress is valid for receiving msgs.\r\n // @param _userApplication - the user app address on this EVM chain\r\n function getReceiveLibraryAddress(address _userApplication) external view returns (address);\r\n\r\n // @notice query if the non-reentrancy guard for send() is on\r\n // @return true if the guard is on. false otherwise\r\n function isSendingPayload() external view returns (bool);\r\n\r\n // @notice query if the non-reentrancy guard for receive() is on\r\n // @return true if the guard is on. false otherwise\r\n function isReceivingPayload() external view returns (bool);\r\n\r\n // @notice get the configuration of the LayerZero messaging library of the specified version\r\n // @param _version - messaging library version\r\n // @param _chainId - the chainId for the pending config change\r\n // @param _userApplication - the contract address of the user application\r\n // @param _configType - type of configuration. every messaging library has its own convention.\r\n function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory);\r\n\r\n // @notice get the send() LayerZero messaging library version\r\n // @param _userApplication - the contract address of the user application\r\n function getSendVersion(address _userApplication) external view returns (uint16);\r\n\r\n // @notice get the lzReceive() LayerZero messaging library version\r\n // @param _userApplication - the contract address of the user application\r\n function getReceiveVersion(address _userApplication) external view returns (uint16);\r\n}\r\n\r\n// File: contracts/lz-contracts/interfaces/ILayerZeroReceiver.sol\r\n\r\n\r\n\r\npragma solidity >=0.5.0;\r\n\r\ninterface ILayerZeroReceiver {\r\n // @notice LayerZero endpoint will invoke this function to deliver the message on the destination\r\n // @param _srcChainId - the source endpoint identifier\r\n // @param _srcAddress - the source sending contract address from the source chain\r\n // @param _nonce - the ordered message nonce\r\n // @param _payload - the signed payload is the UA bytes has encoded to be sent\r\n function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/Context.sol\r\n\r\n\r\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract Context {\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n}\r\n\r\n// File: @openzeppelin/contracts/access/Ownable.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n/**\r\n * @dev Contract module which provides a basic access control mechanism, where\r\n * there is an account (an owner) that can be granted exclusive access to\r\n * specific functions.\r\n *\r\n * By default, the owner account will be the one that deploys the contract. This\r\n * can later be changed with {transferOwnership}.\r\n *\r\n * This module is used through inheritance. It will make available the modifier\r\n * `onlyOwner`, which can be applied to your functions to restrict their use to\r\n * the owner.\r\n */\r\nabstract contract Ownable is Context {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n constructor() {\r\n _transferOwnership(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n _checkOwner();\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if the sender is not the owner.\r\n */\r\n function _checkOwner() internal view virtual {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby disabling any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _transferOwnership(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/lzApp/LzApp.sol\r\n\r\n\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n\r\n\r\n\r\n\r\n/*\r\n * a generic LzReceiver implementation\r\n */\r\nabstract contract LzApp is Ownable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig {\r\n using BytesLib for bytes;\r\n\r\n // ua can not send payload larger than this by default, but it can be changed by the ua owner\r\n uint constant public DEFAULT_PAYLOAD_SIZE_LIMIT = 10000;\r\n\r\n ILayerZeroEndpoint public immutable lzEndpoint;\r\n mapping(uint16 => bytes) public trustedRemoteLookup;\r\n mapping(uint16 => mapping(uint16 => uint)) public minDstGasLookup;\r\n mapping(uint16 => uint) public payloadSizeLimitLookup;\r\n address public precrime;\r\n\r\n event SetPrecrime(address precrime);\r\n event SetTrustedRemote(uint16 _remoteChainId, bytes _path);\r\n event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress);\r\n event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint _minDstGas);\r\n\r\n constructor(address _endpoint) {\r\n lzEndpoint = ILayerZeroEndpoint(_endpoint);\r\n }\r\n\r\n function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual override {\r\n // lzReceive must be called by the endpoint for security\r\n require(_msgSender() == address(lzEndpoint), \"LzApp: invalid endpoint caller\");\r\n\r\n bytes memory trustedRemote = trustedRemoteLookup[_srcChainId];\r\n // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote.\r\n require(_srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), \"LzApp: invalid source sending contract\");\r\n\r\n _blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);\r\n }\r\n\r\n // abstract function - the default behaviour of LayerZero is blocking. See: NonblockingLzApp if you dont need to enforce ordered messaging\r\n function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual;\r\n\r\n function _lzSend(uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams, uint _nativeFee) internal virtual {\r\n bytes memory trustedRemote = trustedRemoteLookup[_dstChainId];\r\n require(trustedRemote.length != 0, \"LzApp: destination chain is not a trusted source\");\r\n _checkPayloadSize(_dstChainId, _payload.length);\r\n lzEndpoint.send{value: _nativeFee}(_dstChainId, trustedRemote, _payload, _refundAddress, _zroPaymentAddress, _adapterParams);\r\n }\r\n\r\n function _checkGasLimit(uint16 _dstChainId, uint16 _type, bytes memory _adapterParams, uint _extraGas) internal view virtual {\r\n uint providedGasLimit = _getGasLimit(_adapterParams);\r\n uint minGasLimit = minDstGasLookup[_dstChainId][_type] + _extraGas;\r\n require(minGasLimit > 0, \"LzApp: minGasLimit not set\");\r\n require(providedGasLimit >= minGasLimit, \"LzApp: gas limit is too low\");\r\n }\r\n\r\n function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint gasLimit) {\r\n require(_adapterParams.length >= 34, \"LzApp: invalid adapterParams\");\r\n assembly {\r\n gasLimit := mload(add(_adapterParams, 34))\r\n }\r\n }\r\n\r\n function _checkPayloadSize(uint16 _dstChainId, uint _payloadSize) internal view virtual {\r\n uint payloadSizeLimit = payloadSizeLimitLookup[_dstChainId];\r\n if (payloadSizeLimit == 0) { // use default if not set\r\n payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT;\r\n }\r\n require(_payloadSize <= payloadSizeLimit, \"LzApp: payload size is too large\");\r\n }\r\n\r\n //---------------------------UserApplication config----------------------------------------\r\n function getConfig(uint16 _version, uint16 _chainId, address, uint _configType) external view returns (bytes memory) {\r\n return lzEndpoint.getConfig(_version, _chainId, address(this), _configType);\r\n }\r\n\r\n // generic config for LayerZero user Application\r\n function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external override onlyOwner {\r\n lzEndpoint.setConfig(_version, _chainId, _configType, _config);\r\n }\r\n\r\n function setSendVersion(uint16 _version) external override onlyOwner {\r\n lzEndpoint.setSendVersion(_version);\r\n }\r\n\r\n function setReceiveVersion(uint16 _version) external override onlyOwner {\r\n lzEndpoint.setReceiveVersion(_version);\r\n }\r\n\r\n function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner {\r\n lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress);\r\n }\r\n\r\n // _path = abi.encodePacked(remoteAddress, localAddress)\r\n // this function set the trusted path for the cross-chain communication\r\n function setTrustedRemote(uint16 _remoteChainId, bytes calldata _path) external onlyOwner {\r\n trustedRemoteLookup[_remoteChainId] = _path;\r\n emit SetTrustedRemote(_remoteChainId, _path);\r\n }\r\n\r\n function setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external onlyOwner {\r\n trustedRemoteLookup[_remoteChainId] = abi.encodePacked(_remoteAddress, address(this));\r\n emit SetTrustedRemoteAddress(_remoteChainId, _remoteAddress);\r\n }\r\n\r\n function getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory) {\r\n bytes memory path = trustedRemoteLookup[_remoteChainId];\r\n require(path.length != 0, \"LzApp: no trusted path record\");\r\n return path.slice(0, path.length - 20); // the last 20 bytes should be address(this)\r\n }\r\n\r\n function setPrecrime(address _precrime) external onlyOwner {\r\n precrime = _precrime;\r\n emit SetPrecrime(_precrime);\r\n }\r\n\r\n function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas) external onlyOwner {\r\n require(_minGas > 0, \"LzApp: invalid minGas\");\r\n minDstGasLookup[_dstChainId][_packetType] = _minGas;\r\n emit SetMinDstGas(_dstChainId, _packetType, _minGas);\r\n }\r\n\r\n // if the size is 0, it means default size limit\r\n function setPayloadSizeLimit(uint16 _dstChainId, uint _size) external onlyOwner {\r\n payloadSizeLimitLookup[_dstChainId] = _size;\r\n }\r\n\r\n //--------------------------- VIEW FUNCTION ----------------------------------------\r\n function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) {\r\n bytes memory trustedSource = trustedRemoteLookup[_srcChainId];\r\n return keccak256(trustedSource) == keccak256(_srcAddress);\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/lzApp/NonblockingLzApp.sol\r\n\r\n\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n\r\n/*\r\n * the default LayerZero messaging behaviour is blocking, i.e. any failed message will block the channel\r\n * this abstract class try-catch all fail messages and store locally for future retry. hence, non-blocking\r\n * NOTE: if the srcAddress is not configured properly, it will still block the message pathway from (srcChainId, srcAddress)\r\n */\r\nabstract contract NonblockingLzApp is LzApp {\r\n using ExcessivelySafeCall for address;\r\n\r\n constructor(address _endpoint) LzApp(_endpoint) {}\r\n\r\n mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) public failedMessages;\r\n\r\n event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason);\r\n event RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash);\r\n\r\n // overriding the virtual function in LzReceiver\r\n function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override {\r\n (bool success, bytes memory reason) = address(this).excessivelySafeCall(gasleft(), 150, abi.encodeWithSelector(this.nonblockingLzReceive.selector, _srcChainId, _srcAddress, _nonce, _payload));\r\n // try-catch all errors/exceptions\r\n if (!success) {\r\n _storeFailedMessage(_srcChainId, _srcAddress, _nonce, _payload, reason);\r\n }\r\n }\r\n\r\n function _storeFailedMessage(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload, bytes memory _reason) internal virtual {\r\n failedMessages[_srcChainId][_srcAddress][_nonce] = keccak256(_payload);\r\n emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload, _reason);\r\n }\r\n\r\n function nonblockingLzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual {\r\n // only internal transaction\r\n require(_msgSender() == address(this), \"NonblockingLzApp: caller must be LzApp\");\r\n _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);\r\n }\r\n\r\n //@notice override this function\r\n function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual;\r\n\r\n function retryMessage(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public payable virtual {\r\n // assert there is message to retry\r\n bytes32 payloadHash = failedMessages[_srcChainId][_srcAddress][_nonce];\r\n require(payloadHash != bytes32(0), \"NonblockingLzApp: no stored message\");\r\n require(keccak256(_payload) == payloadHash, \"NonblockingLzApp: invalid payload\");\r\n // clear the stored message\r\n failedMessages[_srcChainId][_srcAddress][_nonce] = bytes32(0);\r\n // execute the message. revert if it fails again\r\n _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);\r\n emit RetryMessageSuccess(_srcChainId, _srcAddress, _nonce, payloadHash);\r\n }\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/introspection/IERC165.sol\r\n\r\n\r\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the ERC165 standard, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\r\n *\r\n * Implementers can declare support of contract interfaces, which can then be\r\n * queried by others ({ERC165Checker}).\r\n *\r\n * For an implementation, see {ERC165}.\r\n */\r\ninterface IERC165 {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/introspection/ERC165.sol\r\n\r\n\r\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n/**\r\n * @dev Implementation of the {IERC165} interface.\r\n *\r\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\r\n * for the additional interface id that will be supported. For example:\r\n *\r\n * ```solidity\r\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\r\n * }\r\n * ```\r\n *\r\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\r\n */\r\nabstract contract ERC165 is IERC165 {\r\n /**\r\n * @dev See {IERC165-supportsInterface}.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n return interfaceId == type(IERC165).interfaceId;\r\n }\r\n}\r\n\r\n// File: @openzeppelin/contracts/token/ERC721/IERC721.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n/**\r\n * @dev Required interface of an ERC721 compliant contract.\r\n */\r\ninterface IERC721 is IERC165 {\r\n /**\r\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\r\n\r\n /**\r\n * @dev Returns the number of tokens in ``owner``'s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Transfers `tokenId` token from `from` to `to`.\r\n *\r\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\r\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\r\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(address from, address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool approved) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId) external view returns (address operator);\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}\r\n */\r\n function isApprovedForAll(address owner, address operator) external view returns (bool);\r\n}\r\n\r\n// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\r\n\r\n\r\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n/**\r\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\r\n * @dev See https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IERC721Metadata is IERC721 {\r\n /**\r\n * @dev Returns the token collection name.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the token collection symbol.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\r\n */\r\n function tokenURI(uint256 tokenId) external view returns (string memory);\r\n}\r\n\r\n// File: @openzeppelin/contracts/token/ERC721/ERC721.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\r\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\r\n * {ERC721Enumerable}.\r\n */\r\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\r\n using Address for address;\r\n using Strings for uint256;\r\n\r\n // Token name\r\n string private _name;\r\n\r\n // Token symbol\r\n string private _symbol;\r\n\r\n // Mapping from token ID to owner address\r\n mapping(uint256 => address) private _owners;\r\n\r\n // Mapping owner address to token count\r\n mapping(address => uint256) private _balances;\r\n\r\n // Mapping from token ID to approved address\r\n mapping(uint256 => address) private _tokenApprovals;\r\n\r\n // Mapping from owner to operator approvals\r\n mapping(address => mapping(address => bool)) private _operatorApprovals;\r\n\r\n /**\r\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\r\n */\r\n constructor(string memory name_, string memory symbol_) {\r\n _name = name_;\r\n _symbol = symbol_;\r\n }\r\n\r\n /**\r\n * @dev See {IERC165-supportsInterface}.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\r\n return\r\n interfaceId == type(IERC721).interfaceId ||\r\n interfaceId == type(IERC721Metadata).interfaceId ||\r\n super.supportsInterface(interfaceId);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-balanceOf}.\r\n */\r\n function balanceOf(address owner) public view virtual override returns (uint256) {\r\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\r\n return _balances[owner];\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-ownerOf}.\r\n */\r\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\r\n address owner = _ownerOf(tokenId);\r\n require(owner != address(0), \"ERC721: invalid token ID\");\r\n return owner;\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Metadata-name}.\r\n */\r\n function name() public view virtual override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Metadata-symbol}.\r\n */\r\n function symbol() public view virtual override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Metadata-tokenURI}.\r\n */\r\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\r\n _requireMinted(tokenId);\r\n\r\n string memory baseURI = _baseURI();\r\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\r\n }\r\n\r\n /**\r\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\r\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\r\n * by default, can be overridden in child contracts.\r\n */\r\n function _baseURI() internal view virtual returns (string memory) {\r\n return \"\";\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-approve}.\r\n */\r\n function approve(address to, uint256 tokenId) public virtual override {\r\n address owner = ERC721.ownerOf(tokenId);\r\n require(to != owner, \"ERC721: approval to current owner\");\r\n\r\n require(\r\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\r\n \"ERC721: approve caller is not token owner or approved for all\"\r\n );\r\n\r\n _approve(to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-getApproved}.\r\n */\r\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\r\n _requireMinted(tokenId);\r\n\r\n return _tokenApprovals[tokenId];\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-setApprovalForAll}.\r\n */\r\n function setApprovalForAll(address operator, bool approved) public virtual override {\r\n _setApprovalForAll(_msgSender(), operator, approved);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-isApprovedForAll}.\r\n */\r\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\r\n return _operatorApprovals[owner][operator];\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-transferFrom}.\r\n */\r\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\r\n //solhint-disable-next-line max-line-length\r\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\r\n\r\n _transfer(from, to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-safeTransferFrom}.\r\n */\r\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\r\n safeTransferFrom(from, to, tokenId, \"\");\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-safeTransferFrom}.\r\n */\r\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\r\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\r\n _safeTransfer(from, to, tokenId, data);\r\n }\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\r\n *\r\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\r\n * implement alternative mechanisms to perform token transfer, such as signature-based.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\r\n _transfer(from, to, tokenId);\r\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\r\n }\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\r\n */\r\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\r\n return _owners[tokenId];\r\n }\r\n\r\n /**\r\n * @dev Returns whether `tokenId` exists.\r\n *\r\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\r\n *\r\n * Tokens start existing when they are minted (`_mint`),\r\n * and stop existing when they are burned (`_burn`).\r\n */\r\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\r\n return _ownerOf(tokenId) != address(0);\r\n }\r\n\r\n /**\r\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\r\n address owner = ERC721.ownerOf(tokenId);\r\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\r\n }\r\n\r\n /**\r\n * @dev Safely mints `tokenId` and transfers it to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must not exist.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _safeMint(address to, uint256 tokenId) internal virtual {\r\n _safeMint(to, tokenId, \"\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\r\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\r\n */\r\n function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\r\n _mint(to, tokenId);\r\n require(\r\n _checkOnERC721Received(address(0), to, tokenId, data),\r\n \"ERC721: transfer to non ERC721Receiver implementer\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Mints `tokenId` and transfers it to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must not exist.\r\n * - `to` cannot be the zero address.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _mint(address to, uint256 tokenId) internal virtual {\r\n require(to != address(0), \"ERC721: mint to the zero address\");\r\n require(!_exists(tokenId), \"ERC721: token already minted\");\r\n\r\n _beforeTokenTransfer(address(0), to, tokenId, 1);\r\n\r\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\r\n require(!_exists(tokenId), \"ERC721: token already minted\");\r\n\r\n unchecked {\r\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\r\n // Given that tokens are minted one by one, it is impossible in practice that\r\n // this ever happens. Might change if we allow batch minting.\r\n // The ERC fails to describe this case.\r\n _balances[to] += 1;\r\n }\r\n\r\n _owners[tokenId] = to;\r\n\r\n emit Transfer(address(0), to, tokenId);\r\n\r\n _afterTokenTransfer(address(0), to, tokenId, 1);\r\n }\r\n\r\n /**\r\n * @dev Destroys `tokenId`.\r\n * The approval is cleared when the token is burned.\r\n * This is an internal function that does not check if the sender is authorized to operate on the token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _burn(uint256 tokenId) internal virtual {\r\n address owner = ERC721.ownerOf(tokenId);\r\n\r\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\r\n\r\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\r\n owner = ERC721.ownerOf(tokenId);\r\n\r\n // Clear approvals\r\n delete _tokenApprovals[tokenId];\r\n\r\n unchecked {\r\n // Cannot overflow, as that would require more tokens to be burned/transferred\r\n // out than the owner initially received through minting and transferring in.\r\n _balances[owner] -= 1;\r\n }\r\n delete _owners[tokenId];\r\n\r\n emit Transfer(owner, address(0), tokenId);\r\n\r\n _afterTokenTransfer(owner, address(0), tokenId, 1);\r\n }\r\n\r\n /**\r\n * @dev Transfers `tokenId` from `from` to `to`.\r\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\r\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\r\n require(to != address(0), \"ERC721: transfer to the zero address\");\r\n\r\n _beforeTokenTransfer(from, to, tokenId, 1);\r\n\r\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\r\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\r\n\r\n // Clear approvals from the previous owner\r\n delete _tokenApprovals[tokenId];\r\n\r\n unchecked {\r\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\r\n // `from`'s balance is the number of token held, which is at least one before the current\r\n // transfer.\r\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\r\n // all 2**256 token ids to be minted, which in practice is impossible.\r\n _balances[from] -= 1;\r\n _balances[to] += 1;\r\n }\r\n _owners[tokenId] = to;\r\n\r\n emit Transfer(from, to, tokenId);\r\n\r\n _afterTokenTransfer(from, to, tokenId, 1);\r\n }\r\n\r\n /**\r\n * @dev Approve `to` to operate on `tokenId`\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function _approve(address to, uint256 tokenId) internal virtual {\r\n _tokenApprovals[tokenId] = to;\r\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev Approve `operator` to operate on all of `owner` tokens\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\r\n require(owner != operator, \"ERC721: approve to caller\");\r\n _operatorApprovals[owner][operator] = approved;\r\n emit ApprovalForAll(owner, operator, approved);\r\n }\r\n\r\n /**\r\n * @dev Reverts if the `tokenId` has not been minted yet.\r\n */\r\n function _requireMinted(uint256 tokenId) internal view virtual {\r\n require(_exists(tokenId), \"ERC721: invalid token ID\");\r\n }\r\n\r\n /**\r\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\r\n * The call is not executed if the target address is not a contract.\r\n *\r\n * @param from address representing the previous owner of the given token ID\r\n * @param to target address that will receive the tokens\r\n * @param tokenId uint256 ID of the token to be transferred\r\n * @param data bytes optional data to send along with the call\r\n * @return bool whether the call correctly returned the expected magic value\r\n */\r\n function _checkOnERC721Received(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes memory data\r\n ) private returns (bool) {\r\n if (to.isContract()) {\r\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\r\n return retval == IERC721Receiver.onERC721Received.selector;\r\n } catch (bytes memory reason) {\r\n if (reason.length == 0) {\r\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\r\n } else {\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n revert(add(32, reason), mload(reason))\r\n }\r\n }\r\n }\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\r\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\r\n *\r\n * Calling conditions:\r\n *\r\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\r\n * - When `from` is zero, the tokens will be minted for `to`.\r\n * - When `to` is zero, ``from``'s tokens will be burned.\r\n * - `from` and `to` are never both zero.\r\n * - `batchSize` is non-zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\r\n\r\n /**\r\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\r\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\r\n *\r\n * Calling conditions:\r\n *\r\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\r\n * - When `from` is zero, the tokens were minted for `to`.\r\n * - When `to` is zero, ``from``'s tokens were burned.\r\n * - `from` and `to` are never both zero.\r\n * - `batchSize` is non-zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\r\n\r\n /**\r\n * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\r\n *\r\n * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\r\n * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\r\n * that `ownerOf(tokenId)` is `a`.\r\n */\r\n // solhint-disable-next-line func-name-mixedcase\r\n function __unsafe_increaseBalance(address account, uint256 amount) internal {\r\n _balances[account] += amount;\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/token/onft/IONFT721Core.sol\r\n\r\n\r\n\r\npragma solidity >=0.5.0;\r\n\r\n\r\n/**\r\n * @dev Interface of the ONFT Core standard\r\n */\r\ninterface IONFT721Core is IERC165 {\r\n /**\r\n * @dev Emitted when `_tokenIds[]` are moved from the `_sender` to (`_dstChainId`, `_toAddress`)\r\n * `_nonce` is the outbound nonce from\r\n */\r\n event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes indexed _toAddress, uint[] _tokenIds);\r\n event ReceiveFromChain(uint16 indexed _srcChainId, bytes indexed _srcAddress, address indexed _toAddress, uint[] _tokenIds);\r\n event SetMinGasToTransferAndStore(uint256 _minGasToTransferAndStore);\r\n event SetDstChainIdToTransferGas(uint16 _dstChainId, uint256 _dstChainIdToTransferGas);\r\n event SetDstChainIdToBatchLimit(uint16 _dstChainId, uint256 _dstChainIdToBatchLimit);\r\n\r\n /**\r\n * @dev Emitted when `_payload` was received from lz, but not enough gas to deliver all tokenIds\r\n */\r\n event CreditStored(bytes32 _hashedPayload, bytes _payload);\r\n /**\r\n * @dev Emitted when `_hashedPayload` has been completely delivered\r\n */\r\n event CreditCleared(bytes32 _hashedPayload);\r\n\r\n /**\r\n * @dev send token `_tokenId` to (`_dstChainId`, `_toAddress`) from `_from`\r\n * `_toAddress` can be any size depending on the `dstChainId`.\r\n * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token)\r\n * `_adapterParams` is a flexible bytes array to indicate messaging adapter services\r\n */\r\n function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;\r\n /**\r\n * @dev send tokens `_tokenIds[]` to (`_dstChainId`, `_toAddress`) from `_from`\r\n * `_toAddress` can be any size depending on the `dstChainId`.\r\n * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token)\r\n * `_adapterParams` is a flexible bytes array to indicate messaging adapter services\r\n */\r\n function sendBatchFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint[] calldata _tokenIds, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;\r\n\r\n /**\r\n * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`)\r\n * _dstChainId - L0 defined chain id to send tokens too\r\n * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain\r\n * _tokenId - token Id to transfer\r\n * _useZro - indicates to use zro to pay L0 fees\r\n * _adapterParams - flexible bytes array to indicate messaging adapter services in L0\r\n */\r\n function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);\r\n /**\r\n * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`)\r\n * _dstChainId - L0 defined chain id to send tokens too\r\n * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain\r\n * _tokenIds[] - token Ids to transfer\r\n * _useZro - indicates to use zro to pay L0 fees\r\n * _adapterParams - flexible bytes array to indicate messaging adapter services in L0\r\n */\r\n function estimateSendBatchFee(uint16 _dstChainId, bytes calldata _toAddress, uint[] calldata _tokenIds, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);\r\n}\r\n\r\n// File: contracts/lz-contracts/token/onft/ONFT721Core.sol\r\n\r\n\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n\r\n\r\n\r\nabstract contract ONFT721Core is NonblockingLzApp, ERC165, ReentrancyGuard, IONFT721Core {\r\n uint16 public constant FUNCTION_TYPE_SEND = 1;\r\n\r\n struct StoredCredit {\r\n uint16 srcChainId;\r\n address toAddress;\r\n uint256 index; // which index of the tokenIds remain\r\n bool creditsRemain;\r\n }\r\n\r\n uint256 public minGasToTransferAndStore; // min amount of gas required to transfer, and also store the payload\r\n mapping(uint16 => uint256) public dstChainIdToBatchLimit;\r\n mapping(uint16 => uint256) public dstChainIdToTransferGas; // per transfer amount of gas required to mint/transfer on the dst\r\n mapping(bytes32 => StoredCredit) public storedCredits;\r\n\r\n constructor(uint256 _minGasToTransferAndStore, address _lzEndpoint) NonblockingLzApp(_lzEndpoint) {\r\n require(_minGasToTransferAndStore > 0, \"minGasToTransferAndStore must be > 0\");\r\n minGasToTransferAndStore = _minGasToTransferAndStore;\r\n }\r\n\r\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\r\n return interfaceId == type(IONFT721Core).interfaceId || super.supportsInterface(interfaceId);\r\n }\r\n\r\n function estimateSendFee(uint16 _dstChainId, bytes memory _toAddress, uint _tokenId, bool _useZro, bytes memory _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) {\r\n return estimateSendBatchFee(_dstChainId, _toAddress, _toSingletonArray(_tokenId), _useZro, _adapterParams);\r\n }\r\n\r\n function estimateSendBatchFee(uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, bool _useZro, bytes memory _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) {\r\n bytes memory payload = abi.encode(_toAddress, _tokenIds);\r\n return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams);\r\n }\r\n\r\n function sendFrom(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _tokenId, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) public payable virtual override {\r\n _send(_from, _dstChainId, _toAddress, _toSingletonArray(_tokenId), _refundAddress, _zroPaymentAddress, _adapterParams);\r\n }\r\n\r\n function sendBatchFrom(address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) public payable virtual override {\r\n _send(_from, _dstChainId, _toAddress, _tokenIds, _refundAddress, _zroPaymentAddress, _adapterParams);\r\n }\r\n\r\n function _send(address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual {\r\n // allow 1 by default\r\n require(_tokenIds.length > 0, \"tokenIds[] is empty\");\r\n require(_tokenIds.length == 1 || _tokenIds.length <= dstChainIdToBatchLimit[_dstChainId], \"batch size exceeds dst batch limit\");\r\n\r\n for (uint i = 0; i < _tokenIds.length; i++) {\r\n _debitFrom(_from, _dstChainId, _toAddress, _tokenIds[i]);\r\n }\r\n\r\n bytes memory payload = abi.encode(_toAddress, _tokenIds);\r\n\r\n _checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND, _adapterParams, dstChainIdToTransferGas[_dstChainId] * _tokenIds.length);\r\n _lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value);\r\n emit SendToChain(_dstChainId, _from, _toAddress, _tokenIds);\r\n }\r\n\r\n function _nonblockingLzReceive(\r\n uint16 _srcChainId,\r\n bytes memory _srcAddress,\r\n uint64, /*_nonce*/\r\n bytes memory _payload\r\n ) internal virtual override {\r\n // decode and load the toAddress\r\n (bytes memory toAddressBytes, uint[] memory tokenIds) = abi.decode(_payload, (bytes, uint[]));\r\n\r\n address toAddress;\r\n assembly {\r\n toAddress := mload(add(toAddressBytes, 20))\r\n }\r\n\r\n uint nextIndex = _creditTill(_srcChainId, toAddress, 0, tokenIds);\r\n if (nextIndex < tokenIds.length) {\r\n // not enough gas to complete transfers, store to be cleared in another tx\r\n bytes32 hashedPayload = keccak256(_payload);\r\n storedCredits[hashedPayload] = StoredCredit(_srcChainId, toAddress, nextIndex, true);\r\n emit CreditStored(hashedPayload, _payload);\r\n }\r\n\r\n emit ReceiveFromChain(_srcChainId, _srcAddress, toAddress, tokenIds);\r\n }\r\n\r\n // Public function for anyone to clear and deliver the remaining batch sent tokenIds\r\n function clearCredits(bytes memory _payload) external virtual nonReentrant {\r\n bytes32 hashedPayload = keccak256(_payload);\r\n require(storedCredits[hashedPayload].creditsRemain, \"no credits stored\");\r\n\r\n (, uint[] memory tokenIds) = abi.decode(_payload, (bytes, uint[]));\r\n\r\n uint nextIndex = _creditTill(storedCredits[hashedPayload].srcChainId, storedCredits[hashedPayload].toAddress, storedCredits[hashedPayload].index, tokenIds);\r\n require(nextIndex > storedCredits[hashedPayload].index, \"not enough gas to process credit transfer\");\r\n\r\n if (nextIndex == tokenIds.length) {\r\n // cleared the credits, delete the element\r\n delete storedCredits[hashedPayload];\r\n emit CreditCleared(hashedPayload);\r\n } else {\r\n // store the next index to mint\r\n storedCredits[hashedPayload] = StoredCredit(storedCredits[hashedPayload].srcChainId, storedCredits[hashedPayload].toAddress, nextIndex, true);\r\n }\r\n }\r\n\r\n // When a srcChain has the ability to transfer more chainIds in a single tx than the dst can do.\r\n // Needs the ability to iterate and stop if the minGasToTransferAndStore is not met\r\n function _creditTill(uint16 _srcChainId, address _toAddress, uint _startIndex, uint[] memory _tokenIds) internal returns (uint256){\r\n uint i = _startIndex;\r\n while (i < _tokenIds.length) {\r\n // if not enough gas to process, store this index for next loop\r\n if (gasleft() < minGasToTransferAndStore) break;\r\n\r\n _creditTo(_srcChainId, _toAddress, _tokenIds[i]);\r\n i++;\r\n }\r\n\r\n // indicates the next index to send of tokenIds,\r\n // if i == tokenIds.length, we are finished\r\n return i;\r\n }\r\n\r\n function setMinGasToTransferAndStore(uint256 _minGasToTransferAndStore) external onlyOwner {\r\n require(_minGasToTransferAndStore > 0, \"minGasToTransferAndStore must be > 0\");\r\n minGasToTransferAndStore = _minGasToTransferAndStore;\r\n emit SetMinGasToTransferAndStore(_minGasToTransferAndStore);\r\n }\r\n\r\n // ensures enough gas in adapter params to handle batch transfer gas amounts on the dst\r\n function setDstChainIdToTransferGas(uint16 _dstChainId, uint256 _dstChainIdToTransferGas) external onlyOwner {\r\n require(_dstChainIdToTransferGas > 0, \"dstChainIdToTransferGas must be > 0\");\r\n dstChainIdToTransferGas[_dstChainId] = _dstChainIdToTransferGas;\r\n emit SetDstChainIdToTransferGas(_dstChainId, _dstChainIdToTransferGas);\r\n }\r\n\r\n // limit on src the amount of tokens to batch send\r\n function setDstChainIdToBatchLimit(uint16 _dstChainId, uint256 _dstChainIdToBatchLimit) external onlyOwner {\r\n require(_dstChainIdToBatchLimit > 0, \"dstChainIdToBatchLimit must be > 0\");\r\n dstChainIdToBatchLimit[_dstChainId] = _dstChainIdToBatchLimit;\r\n emit SetDstChainIdToBatchLimit(_dstChainId, _dstChainIdToBatchLimit);\r\n }\r\n\r\n function _debitFrom(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _tokenId) internal virtual;\r\n\r\n function _creditTo(uint16 _srcChainId, address _toAddress, uint _tokenId) internal virtual;\r\n\r\n function _toSingletonArray(uint element) internal pure returns (uint[] memory) {\r\n uint[] memory array = new uint[](1);\r\n array[0] = element;\r\n return array;\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/token/onft/IONFT721.sol\r\n\r\n\r\n\r\npragma solidity >=0.5.0;\r\n\r\n\r\n\r\n/**\r\n * @dev Interface of the ONFT standard\r\n */\r\ninterface IONFT721 is IONFT721Core, IERC721 {\r\n\r\n}\r\n\r\n// File: contracts/lz-contracts/token/onft/ONFT721.sol\r\n\r\n\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n\r\n\r\n// NOTE: this ONFT contract has no public minting logic.\r\n// must implement your own minting logic in child classes\r\ncontract ONFT721 is ONFT721Core, ERC721, IONFT721 {\r\n constructor(string memory _name, string memory _symbol, uint256 _minGasToTransfer, address _lzEndpoint) ERC721(_name, _symbol) ONFT721Core(_minGasToTransfer, _lzEndpoint) {}\r\n\r\n function supportsInterface(bytes4 interfaceId) public view virtual override(ONFT721Core, ERC721, IERC165) returns (bool) {\r\n return interfaceId == type(IONFT721).interfaceId || super.supportsInterface(interfaceId);\r\n }\r\n\r\n function _debitFrom(address _from, uint16, bytes memory, uint _tokenId) internal virtual override {\r\n require(_isApprovedOrOwner(_msgSender(), _tokenId), \"ONFT721: send caller is not owner nor approved\");\r\n require(ERC721.ownerOf(_tokenId) == _from, \"ONFT721: send from incorrect owner\");\r\n _transfer(_from, address(this), _tokenId);\r\n }\r\n\r\n function _creditTo(uint16, address _toAddress, uint _tokenId) internal virtual override {\r\n require(!_exists(_tokenId) || (_exists(_tokenId) && ERC721.ownerOf(_tokenId) == address(this)));\r\n if (!_exists(_tokenId)) {\r\n _safeMint(_toAddress, _tokenId);\r\n } else {\r\n _transfer(address(this), _toAddress, _tokenId);\r\n }\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/token/onft/extension/UniversalONFT721.sol\r\n\r\n\r\n\r\npragma solidity ^0.8.0;\r\n\r\n\r\n/// @title Interface of the UniversalONFT standard\r\ncontract UniversalONFT721 is ONFT721 {\r\n uint public nextMintId;\r\n uint public maxMintId;\r\n uint256 public cost = 0.00023 ether;\r\n\r\n /// @notice Constructor for the UniversalONFT\r\n /// @param _name the name of the token\r\n /// @param _symbol the token symbol\r\n /// @param _layerZeroEndpoint handles message transmission across chains\r\n /// @param _startMintId the starting mint number on this chain\r\n /// @param _endMintId the max number of mints on this chain\r\n constructor(string memory _name, string memory _symbol, uint256 _minGasToTransfer, address _layerZeroEndpoint, uint _startMintId, uint _endMintId) ONFT721(_name, _symbol, _minGasToTransfer, _layerZeroEndpoint) {\r\n nextMintId = _startMintId;\r\n maxMintId = _endMintId;\r\n }\r\n\r\n /// @notice Mint your ONFT\r\n function mint() external payable {\r\n require(nextMintId <= maxMintId, \"UniversalONFT721: max mint limit reached\");\r\n require(msg.value >= cost, \"Insufficient funds\");\r\n\r\n uint newId = nextMintId;\r\n nextMintId++;\r\n\r\n _safeMint(msg.sender, newId);\r\n }\r\n}\r\n\r\n// File: contracts/lz-contracts/examples/ExampleUniversalONFT721.sol\r\n\r\n\r\n\r\npragma solidity ^0.8.0;\r\n\r\n// __ __ _ _ _ _ _ \r\n// | \/ | | | | (_) | | (_) \r\n// | \\ / |_ _| | |_ _ ___| |__ __ _ _ _ __ \r\n// | |\/| | | | | | __| |/ __| '_ \\ / _` | | '_ \\ \r\n// | | | | |_| | | |_| | (__| | | | (_| | | | | |\r\n// |_|__|_|\\__,_|_|\\__|_|\\___|_| |_|\\__,_|_|_| |_|\r\n// | __ \\ \r\n// | |__) |____ _____ _ __ \r\n// | ___/ _ \\ \\ /\\ / / _ \\ '__| \r\n// | | | (_) \\ V V / __/ | \r\n// |_| \\___/ \\_/\\_/ \\___|_| \r\n// \r\n \r\n\r\n\r\n/// @title A LayerZero UniversalONFT example\r\n/// @notice You can use this to mint ONFT and send nftIds across chain.\r\n/// Each contract deployed to a chain should carefully set a `_startMintIndex` and a `_maxMint`\r\n/// value to set a range of allowed mintable nftIds (so that no two chains can mint the same id!)\r\ncontract LayerZeroMultichainPowerXLV2 is UniversalONFT721 {\r\n string public baseTokenURI;\r\n constructor(\r\n string memory _baseTokenURI,\r\n uint256 _minGasToStore, \r\n address _layerZeroEndpoint, \r\n uint _startMintId, \r\n uint _endMintId\r\n ) UniversalONFT721(\"LayerZero Multichain Power XL V2\", \"LZPOWERXLV2\", \r\n _minGasToStore, \r\n _layerZeroEndpoint, \r\n _startMintId, \r\n _endMintId) {\r\n setBaseURI(_baseTokenURI);\r\n }\r\n\r\n /// @notice Set the baseTokenURI\r\n /// @param _baseTokenURI to set\r\n function setBaseURI(string memory _baseTokenURI) public onlyOwner {\r\n baseTokenURI = _baseTokenURI;\r\n }\r\n\r\n /// @notice Get the base URI\r\n function _baseURI() internal view override returns (string memory) {\r\n return baseTokenURI;\r\n }\r\n\r\n function tokenURI(uint256 _nftId)\r\n public\r\n view\r\n override(ERC721)\r\n returns (string memory)\r\n {\r\n require(_exists(_nftId), \"Not exist\");\r\n\r\n string memory currentBaseURI = _baseURI();\r\n return currentBaseURI;\r\n }\r\n\r\n function withdraw() public payable onlyOwner {\r\n (bool os, ) = payable(owner()).call{value: address(this).balance}(\"\");\r\n require(os, \"Failed to send Ether\");\r\n }\r\n}",
"ABI": "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_baseTokenURI\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_minGasToStore\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_layerZeroEndpoint\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_startMintId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_endMintId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_hashedPayload\",\"type\":\"bytes32\"}],\"name\":\"CreditCleared\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_hashedPayload\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"CreditStored\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_reason\",\"type\":\"bytes\"}],\"name\":\"MessageFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"indexed\":true,\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_toAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"ReceiveFromChain\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_payloadHash\",\"type\":\"bytes32\"}],\"name\":\"RetryMessageSuccess\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"SendToChain\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_dstChainIdToBatchLimit\",\"type\":\"uint256\"}],\"name\":\"SetDstChainIdToBatchLimit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_dstChainIdToTransferGas\",\"type\":\"uint256\"}],\"name\":\"SetDstChainIdToTransferGas\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_type\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_minDstGas\",\"type\":\"uint256\"}],\"name\":\"SetMinDstGas\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_minGasToTransferAndStore\",\"type\":\"uint256\"}],\"name\":\"SetMinGasToTransferAndStore\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"precrime\",\"type\":\"address\"}],\"name\":\"SetPrecrime\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_path\",\"type\":\"bytes\"}],\"name\":\"SetTrustedRemote\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_remoteAddress\",\"type\":\"bytes\"}],\"name\":\"SetTrustedRemoteAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_PAYLOAD_SIZE_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"FUNCTION_TYPE_SEND\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"baseTokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"clearCredits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cost\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"dstChainIdToBatchLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"dstChainIdToTransferGas\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"_useZro\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"estimateSendBatchFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nativeFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"zroFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_useZro\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"estimateSendFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nativeFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"zroFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"name\":\"failedMessages\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"}],\"name\":\"forceResumeReceive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"_chainId\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_configType\",\"type\":\"uint256\"}],\"name\":\"getConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"}],\"name\":\"getTrustedRemoteAddress\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"}],\"name\":\"isTrustedRemote\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lzEndpoint\",\"outputs\":[{\"internalType\":\"contract ILayerZeroEndpoint\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"lzReceive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxMintId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"minDstGasLookup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minGasToTransferAndStore\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextMintId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"nonblockingLzReceive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"payloadSizeLimitLookup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"precrime\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_srcAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"}],\"name\":\"retryMessage\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256[]\",\"name\":\"_tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"address payable\",\"name\":\"_refundAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_zroPaymentAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"sendBatchFrom\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_toAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address payable\",\"name\":\"_refundAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_zroPaymentAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_adapterParams\",\"type\":\"bytes\"}],\"name\":\"sendFrom\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_baseTokenURI\",\"type\":\"string\"}],\"name\":\"setBaseURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"_chainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_configType\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_config\",\"type\":\"bytes\"}],\"name\":\"setConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_dstChainIdToBatchLimit\",\"type\":\"uint256\"}],\"name\":\"setDstChainIdToBatchLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_dstChainIdToTransferGas\",\"type\":\"uint256\"}],\"name\":\"setDstChainIdToTransferGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"_packetType\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_minGas\",\"type\":\"uint256\"}],\"name\":\"setMinDstGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minGasToTransferAndStore\",\"type\":\"uint256\"}],\"name\":\"setMinGasToTransferAndStore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_dstChainId\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"_size\",\"type\":\"uint256\"}],\"name\":\"setPayloadSizeLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_precrime\",\"type\":\"address\"}],\"name\":\"setPrecrime\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"}],\"name\":\"setReceiveVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_version\",\"type\":\"uint16\"}],\"name\":\"setSendVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_path\",\"type\":\"bytes\"}],\"name\":\"setTrustedRemote\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_remoteChainId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"_remoteAddress\",\"type\":\"bytes\"}],\"name\":\"setTrustedRemoteAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"storedCredits\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"srcChainId\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"toAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"creditsRemain\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_nftId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"trustedRemoteLookup\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}]",
"ContractName": "LayerZeroMultichainPowerXLV2",
"CompilerVersion": "v0.8.18+commit.87f61d96",
"OptimizationUsed": "1",
"Runs": "200",
"ConstructorArguments": "00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000088b8000000000000000000000000b6319cc6c8c27a8f5daf0dd3df91ea35c4720dd700000000000000000000000000000000000000000000000000000000001e848100000000000000000000000000000000000000000000000000000000002dc6c00000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d656146614d52563774346e3743337975394b594370716657384466433271684d53636e4351565961516a696f0000000000000000000000",
"EVMVersion": "Default",
"Library": "",
"LicenseType": "MIT",
"Proxy": "0",
"Implementation": "",
"SwarmSource": "ipfs://8a87353b5fced689d8706993e09f4aedf88de0a138b478781f98307e5936eee8"
}
]
}
Returns a contract's deployer address and transaction hash it was created, up to 5 at a time.
https://api.lineascan.build/api
?module=contract
&action=getcontractcreation
&contractaddresses=0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f,0xba49765B67Ba05070027297E8C6240AB7D1d10FB
Query Parameters
Sample Response
{
"status": "1",
"message": "OK",
"result": [
{
"contractAddress": "0xba49765b67ba05070027297e8c6240ab7d1d10fb",
"contractCreator": "0xe9136362bb1c97019eab596ea9047f935644bb49",
"txHash": "0x4e44443c640b80f5c359f14cefc551c6af319e0eeecb67c23f7c3a6f135e9370"
},
{
"contractAddress": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
"contractCreator": "0x83fd7b993f408e23d4c146896a951830619a5bc9",
"txHash": "0x2bfe7e837e97f2b620f51fcf7d2dab90c673e043f7c9a429754caf59e33c40fa"
}
]
}
Submits a contract source code to LineaScan for verification.
Requires a valid LineaScan API key, it will be rejected otherwise
Only supports HTTP POST due to max transfer size limitations for HTTP GET
Supports up to 10 different library pairs
Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files.
List of supported solc versions, only solc version v0.4.11 and above is supported e.g. v0.4.25+commit.59dbf8f1
Upon successful submission you will receive a GUID (50 characters) as a receipt
You may use this GUID to track the status of your submission
Verified Source Codes will be displayed at the Verified Contracts page.
See Demo Source Verification Submission Code at Source Code Verification Sample.
//Submit Source Code for Verification
$.ajax({
type: "POST", //Only POST supported
url: "//api.lineascan.build/api", //Set to the correct API url for Other Networks
data: {
apikey: $('#apikey').val(), //A valid API-Key is required
module: 'contract', //Do not change
action: 'verifysourcecode', //Do not change
contractaddress: $('#contractaddress').val(), //Contract Address starts with 0x...
sourceCode: $('#sourceCode').val(), //Contract Source Code (Flattened if necessary)
codeformat: $('#codeformat').val(), //solidity-single-file (default) or solidity-standard-json-input (for std-input-json-format support
contractname: $('#contractname').val(), //ContractName (if codeformat=solidity-standard-json-input, then enter contractname as ex: erc20.sol:erc20)
compilerversion: $('#compilerversion').val(), // see https://lineascan.build/solcversions for list of support versions
optimizationUsed: $('#optimizationUsed').val(), //0 = No Optimization, 1 = Optimization used (applicable when codeformat=solidity-single-file)
runs: 200, //set to 200 as default unless otherwise (applicable when codeformat=solidity-single-file)
constructorArguements: $('#constructorArguements').val(), //if applicable
evmversion: $('#evmVersion').val(), //leave blank for compiler default, homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul (applicable when codeformat=solidity-single-file)
licenseType: $('#licenseType').val(), //Valid codes 1-14 where 1=No License .. 14=Business Source License 1.1, see https://lineascan.build/contract-license-types
libraryname1: $('#libraryname1').val(), //if applicable, a matching pair with libraryaddress1 required
libraryaddress1: $('#libraryaddress1').val(), //if applicable, a matching pair with libraryname1 required
libraryname2: $('#libraryname2').val(), //if applicable, matching pair required
libraryaddress2: $('#libraryaddress2').val(), //if applicable, matching pair required
libraryname3: $('#libraryname3').val(), //if applicable, matching pair required
libraryaddress3: $('#libraryaddress3').val(), //if applicable, matching pair required
libraryname4: $('#libraryname4').val(), //if applicable, matching pair required
libraryaddress4: $('#libraryaddress4').val(), //if applicable, matching pair required
libraryname5: $('#libraryname5').val(), //if applicable, matching pair required
libraryaddress5: $('#libraryaddress5').val(), //if applicable, matching pair required
libraryname6: $('#libraryname6').val(), //if applicable, matching pair required
libraryaddress6: $('#libraryaddress6').val(), //if applicable, matching pair required
libraryname7: $('#libraryname7').val(), //if applicable, matching pair required
libraryaddress7: $('#libraryaddress7').val(), //if applicable, matching pair required
libraryname8: $('#libraryname8').val(), //if applicable, matching pair required
libraryaddress8: $('#libraryaddress8').val(), //if applicable, matching pair required
libraryname9: $('#libraryname9').val(), //if applicable, matching pair required
libraryaddress9: $('#libraryaddress9').val(), //if applicable, matching pair required
libraryname10: $('#libraryname10').val(), //if applicable, matching pair required
libraryaddress10: $('#libraryaddress10').val() //if applicable, matching pair required
},
success: function (result) {
console.log(result);
if (result.status == "1") {
//1 = submission success, use the guid returned (result.result) to check the status of your submission.
// Average time of processing is 30-60 seconds
document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;
// result.result is the GUID receipt for the submission, you can use this guid for checking the verification status
} else {
//0 = error
document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;
}
console.log("status : " + result.status);
console.log("result : " + result.result);
},
error: function (result) {
console.log("error!");
document.getElementById("postresult").innerHTML = "Unexpected Error"
}
});
//Check Source Code Verification Status
$.ajax({
type: "GET",
url: "//api.lineascan.build/api",
data: {
apikey: $('#apikey').val(),
guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above
module: "contract",
action: "checkverifystatus"
},
success: function (result) {
console.log("status : " + result.status); //0=Error, 1=Pass
console.log("message : " + result.message); //OK, NOTOK
console.log("result : " + result.result); //result explanation
$('#guidstatus').html(">> " + result.result);
},
error: function (result) {
alert('error');
}
});
Submits a proxy contract source code to LineaScan for verification.
Requires a valid LineaScan API key, it will be rejected otherwise
Current daily limit of 100 submissions per day per user (subject to change)
Only supports HTTP post
Upon successful submission you will receive a GUID (50 characters) as a receipt
You may use this GUID to track the status of your submission
Verified proxy contracts will display the "Read/Write as Proxy" of the implementation contract under the contract address's contract tab
// example with only the mandatory contract address parameter
curl -d "address=0xcbdcd3815b5f975e1a2c944a9b2cd1c985a1cb7f" "https://api.lineascan.build/api?module=contract&action=verifyproxycontract&apikey=YourApiKeyToken"
// example using the expectedimplementation optional parameter
// the expectedimplementation enforces a check to ensure the returned implementation contract address == address picked up by the verifier
curl -d "address=0xbc46363a7669f6e12353fa95bb067aead3675c29&expectedimplementation=0xe45a5176bc0f2c1198e2451c4e4501d4ed9b65a6" "https://api.lineascan.build/api?module=contract&action=verifyproxycontract&apikey=YourApiKeyToken"
// OK
{"status":"1","message":"OK","result":"gwgrrnfy56zf6vc1fljuejwg6pelnc5yns6fg6y2i6zfpgzquz"}
// NOTOK
{"status":"0","message":"NOTOK","result":"Invalid API Key"}
curl "https://api.lineascan.build/api?module=contract&action=checkproxyverification&guid=gwgrrnfy56zf6vc1fljuejwg6pelnc5yns6fg6y2i6zfpgzquz&apikey=YourApiKeyToken"
// OK
{"status":"1","message":"OK","result":"The proxy's (0xbc46363a7669f6e12353fa95bb067aead3675c29) implementation contract is found at 0xe45a5176bc0f2c1198e2451c4e4501d4ed9b65a6 and is successfully updated."}
// NOTOK
{"status":"0","message":"NOTOK","result":"A corresponding implementation contract was unfortunately not detected for the proxy address."}
Tip : You can also download a CSV list of verified contracts addresses of which the code publishers have provided a corresponding Open Source license for redistribution.
Parameter | Description |
---|---|
Try this endpoint in your browser
Parameter | Description |
---|---|
Note : This endpoint is limited to 100 verifications/day, regardless of API PRO tier.
Note: Upon successful submission, a GUID is returned, which can be used to check for submission status.
address
the contract address
that has a verified source code
address
the contract address
that has a verified source code
contractaddresses
the contract address
, up to 5 at a time