diff --git a/src/createTokenBridgePrepareTransactionRequest.ts b/src/createTokenBridgePrepareTransactionRequest.ts index 63d6d2df..c517c58e 100644 --- a/src/createTokenBridgePrepareTransactionRequest.ts +++ b/src/createTokenBridgePrepareTransactionRequest.ts @@ -13,6 +13,7 @@ import { import { Prettify } from './types/utils'; import { WithTokenBridgeCreatorAddressOverride } from './types/createTokenBridgeTypes'; import { getTokenBridgeCreatorAddress } from './utils/getTokenBridgeCreatorAddress'; +import { isTokenBridgeDeployed } from './createTokenBridge'; export type TransactionRequestRetryableGasOverrides = { maxSubmissionCostForFactory?: GasOverrideOptions; @@ -50,6 +51,17 @@ export async function createTokenBridgePrepareTransactionRequest< }: CreateTokenBridgePrepareTransactionRequestParams) { const chainId = validateParentChain(parentChainPublicClient); + const isTokenBridgeAlreadyDeployed = await isTokenBridgeDeployed({ + parentChainPublicClient, + orbitChainPublicClient, + tokenBridgeCreatorAddress: tokenBridgeCreatorAddressOverride, + rollupAddress: params.rollup, + }); + + if (isTokenBridgeAlreadyDeployed) { + throw new Error(`Token bridge contracts for Rollup ${params.rollup} are already deployed`); + } + const tokenBridgeCreatorAddress = tokenBridgeCreatorAddressOverride ?? getTokenBridgeCreatorAddress(parentChainPublicClient);