Skip to main content

Bridging Tokens

Learn how to bridge omnichain tokens using Holograph SDK. This feature enables contracts, fungible, and non-fungible tokens to be bridged between different chains. To learn how to bridge, refer to the following sections:


Bridging NFTs

To bridge NFTs using the Holograph SDK, make sure to have the following prerequisites.

Prerequisites

1. Instantiate BridgeNFT Class

Create an instance of the BridgeNFT class, specifying the necessary parameters. Pay attention to the following:

  • Ensure that the contract exists on the destinationChainId and the sourceChainId. To bridge an NFT, the contract must be deployed to at least two chains.
src/holograph/bridge-nft.ts
import { BridgeNFT } from "@holographxyz/sdk"
import { networks } from "@holographxyz/networks"

import { holographConfig, wallet } from "./config"
import { myCollection } from "./deploy"
import { myNFT } from "./mint"

const bridgeNFT = new BridgeNFT(holographConfig, {
sourceChainId: myCollection.primaryChainId,
destinationChainId: networks.ethereum.chain,
contractAddress: myCollection.collectionAddress,
tokenId: myNFT.tokenId,
wallet,
})

2. Make Bridge Out Request

Call the bridgeOut function.

src/holograph/bridge-nft.ts
const bridgeOutNFTTx = await bridgeNFT.bridgeOut()

For more information, check out the BridgeNFT class reference.


Bridging Contracts

To bridge contracts with the Holograph SDK, make sure to have the following prerequisites.

Prerequisites

1. Instantiate BridgeCollection Class

Create an instance of the BridgeCollection class, specifying the necessary parameters. The erc721DeploymentConfig contains all the necessary information of a contract. This information remains the same across all networks.

src/holograph/bridge-collection.ts
import { BridgeCollection } from "@holographxyz/sdk"

import { holographConfig, wallet } from "./config"
import { myCollection } from "./deploy"

const erc721DeploymentConfig = myCollection.createErc721DeploymentConfig(
wallet.account.address
)

const bridgeCollection = new BridgeCollection(holographConfig, {
sourceChainId: myCollection.primaryChainId,
contractAddress: myCollection.collectionAddress,
erc721DeploymentConfig,
wallet,
})

2. Make Bridge Out Request

Call the bridgeOut function, providing the destinationChainId of the desired network. Pay attention to the following:

  • Ensure the destinationChainId is one of the supported chains enabled by Holograph for bridges.
src/holograph/bridge-collection.ts
import { networks } from "@holographxyz/networks"

const destinationChainId = networks.polygon.chain

const bridgeOutCollectionTx = await bridgeCollection.bridgeOut(
destinationChainId
)

For more information, check out the BridgeCollection class reference.


Bridging Fungible Tokens

This section is currently under development. Stay tuned for updates.

For more information, check out the BridgeErc20 class reference.