hNFT BridgehFT BridgeGas Refuel

1. Constants

Addresses (hNFT)

"optimism":"0x2a5c54c625220cb2166C94DD9329be1F8785977D",
"celo":"0x7f4CFDf669d7a5d4Adb05917081634875E21Df47",
"avalanche":"0x7daC480d20f322D2ef108A59A465CCb5749371c4",
"polygon zkevm":"0x7daC480d20f322D2ef108A59A465CCb5749371c4",
"binance smart chain":"0xf3D41b377c93fA5C3b0071966f1811c5063fAD40",
"moonbeam":"0x7daC480d20f322D2ef108A59A465CCb5749371c4",
"gnosis":"0x7dac480d20f322d2ef108a59a465ccb5749371c4",
"arbitrum":"0x7daC480d20f322D2ef108A59A465CCb5749371c4",
"polygon":"0x7daC480d20f322D2ef108A59A465CCb5749371c4",
"base":"0x7dac480d20f322d2ef108a59a465ccb5749371c4",
"scroll":"0x7daC480d20f322D2ef108A59A465CCb5749371c4",
"ethereum":"0x7daC480d20f322D2ef108A59A465CCb5749371c4",

Addresses (hFT)

"optimism":"0x32F05f390217990404392a4DdAF39D31Db4aFf77",
"celo":"0xad8676147360dBc010504aB69C7f1b1877109527",
"avalanche":"0x904550e0D182cd4aEe0D305891c666a212EC8F01",
"polygon zkevm":"0x46B4eDaA761eF8d2934e9F7AAf32B5Bf2C9C9F67",
"binance smart chain":"0x7b4f475d32f9c65de1834A578859F9823bE3c5Cf",
"moonbeam":"0xf3D41b377c93fA5C3b0071966f1811c5063fAD40",
"gnosis":"0xFD34afDFbaC1E47aFC539235420e4bE4A206f26D",
"arbitrum":"0xFD34afDFbaC1E47aFC539235420e4bE4A206f26D",
"polygon":"0x574E69C50e7D13B3d1B364BF0D48285A5aE2dF56",
"base":"0x5454cF5584939f7f884e95DBA33FECd6D40B8fE2",
"scroll":"0x904550e0D182cd4aEe0D305891c666a212EC8F01",
"ethereum":"0xf3D41b377c93fA5C3b0071966f1811c5063fAD40",

Domains

"optimism":10,
"celo":42220,
"avalanche":43114,
"polygon zkevm":1101,
"binance smart chain":56,
"moonbeam":1284,
"gnosis":100,
"arbitrum":42161,
"polygon":137,
"base":8453,
"scroll":534352,
"ethereum":1,

Human readable ABI (hNFT)

[
"function fee() external view returns (uint256 fee)",
"function mint(uint256 amount) external payable",
"function quoteBridge(uint32 _destination) external view returns (uint nativeFee)",
"function bridgeNFT(uint32 _destination, uint256 _Id) external payable virtual returns (bytes32 messageId)",
]

JSON ABI (hNFT)

[
  {
    "type": "function",
    "name": "fee",
    "constant": true,
    "stateMutability": "view",
    "payable": false,
    "inputs": [],
    "outputs": [
      {
        "type": "uint256",
        "name": "fee"
      }
    ]
  },
  {
    "type": "function",
    "name": "mint",
    "constant": false,
    "stateMutability": "payable",
    "payable": true,
    "inputs": [
      {
        "type": "uint256",
        "name": "amount"
      }
    ],
    "outputs": []
  },
  {
    "type": "function",
    "name": "quoteBridge",
    "constant": true,
    "stateMutability": "view",
    "payable": false,
    "inputs": [
      {
        "type": "uint32",
        "name": "_destination"
      }
    ],
    "outputs": [
      {
        "type": "uint256",
        "name": "nativeFee"
      }
    ]
  },
  {
    "type": "function",
    "name": "bridgeNFT",
    "constant": false,
    "stateMutability": "payable",
    "payable": true,
    "inputs": [
      {
        "type": "uint32",
        "name": "_destination"
      },
      {
        "type": "uint256",
        "name": "_Id"
      }
    ],
    "outputs": [
      {
        "type": "bytes32",
        "name": "messageId"
      }
    ]
  }
]

Human readable ABI (hFT)

[
"function fee() external view returns (uint256 fee)",
"function mint(address _to, uint256 _amount) external payable",
"function quoteBridge(uint32 _destination) external view returns (uint nativeFee)",
"function bridgeHFT(uint32 _destination, uint256 _amount) external payable virtual returns (bytes32 messageId)",
]

JSON ABI (hFT)

[
  {
    "type": "function",
    "name": "fee",
    "constant": true,
    "stateMutability": "view",
    "payable": false,
    "inputs": [],
    "outputs": [
      {
        "type": "uint256",
        "name": "fee"
      }
    ]
  },
  {
    "type": "function",
    "name": "mint",
    "constant": false,
    "stateMutability": "payable",
    "payable": true,
    "inputs": [
      {
        "type": "uint256",
        "name": "amount"
      }
    ],
    "outputs": []
  },
  {
    "type": "function",
    "name": "quoteBridge",
    "constant": true,
    "stateMutability": "view",
    "payable": false,
    "inputs": [
      {
        "type": "uint32",
        "name": "_destination"
      }
    ],
    "outputs": [
      {
        "type": "uint256",
        "name": "nativeFee"
      }
    ]
  },
  {
    "type": "function",
    "name": "bridgeNFT",
    "constant": false,
    "stateMutability": "payable",
    "payable": true,
    "inputs": [
      {
        "type": "uint32",
        "name": "_destination"
      },
      {
        "type": "uint256",
        "name": "_Id"
      }
    ],
    "outputs": [
      {
        "type": "bytes32",
        "name": "messageId"
      }
    ]
  }
]

2. Minting Merkly Hyperlane NFT

const fee = await contract.fee();
const amount = 1;
const tx = await contract.mint(amount, { value: fee.mul(amount) });
const receipt = await tx.wait();

let mintIDHex;
if (network == "Polygon")
mintIDHex = receipt.logs[1].topics[3]
if (receipt.logs.length === 1)
mintIDHex = receipt.logs[0].topics[3]
else
mintIDHex = receipt.logs[2].topics[3]

const mintID = parseInt(mintIDHex, 16);

3. Quote & Bridge hNFT

const domain = 10; // Optimism 
const quote = await contract.quoteBridge(domain);
const tx = await contract.bridgeNFT(domain, mintID, { value: quote });

4. Minting Merkly Hyperlane FT

const fee = await contract.fee();
const amount = 1;
const tx = await contract.mint(address, amount, { value: fee.mul(amount) });
const receipt = await tx.wait();

3. Quote & Bridge hFT

const domain = 10; // Optimism 
const quote = await contract.quoteBridge(domain);
const tx = await contract.bridgeNFT(domain, amount.mul(BigNumber.from(10).pow(18)), { value: quote });