diff --git a/apps/remix-ide/src/blockchain/blockchain.tsx b/apps/remix-ide/src/blockchain/blockchain.tsx index b1b21a4ec5..5ce26a8249 100644 --- a/apps/remix-ide/src/blockchain/blockchain.tsx +++ b/apps/remix-ide/src/blockchain/blockchain.tsx @@ -10,7 +10,7 @@ import { VMProvider } from './providers/vm' import { InjectedProvider } from './providers/injected' import { NodeProvider } from './providers/node' import { execution, EventManager, helpers } from '@remix-project/remix-lib' -import { etherScanLink } from './helper' +import { etherScanLink, getBlockScoutUrl } from './helper' import { logBuilder, cancelUpgradeMsg, cancelProxyMsg, addressToString } from '@remix-ui/helper' import { Provider } from '@remix-ui/environment-explorer' @@ -730,19 +730,34 @@ export class Blockchain extends Plugin { ) web3Runner.event.register('transactionBroadcasted', (txhash) => { - this.executionContext.detectNetwork((error, network) => { + this.executionContext.detectNetwork(async (error, network) => { if (error || !network) return if (network.name === 'VM') return const viewEtherScanLink = etherScanLink(network.name, txhash) - + const viewBlockScoutLink = await getBlockScoutUrl(network.id, txhash) if (viewEtherScanLink) { - this.call( - 'terminal', - 'logHtml', - - view on etherscan - - ) + if (viewBlockScoutLink) { + this.call( + 'terminal', + 'logHtml', +
+ + view on Etherscan + + + view on Blockscout + +
+ ) + } else { + this.call( + 'terminal', + 'logHtml', + + view on Etherscan + + ) + } } }) }) diff --git a/apps/remix-ide/src/blockchain/helper.ts b/apps/remix-ide/src/blockchain/helper.ts index 5dd37e7378..d8b7159bef 100644 --- a/apps/remix-ide/src/blockchain/helper.ts +++ b/apps/remix-ide/src/blockchain/helper.ts @@ -11,4 +11,17 @@ export function etherScanLink (network: string, hash: string): string { if (transactionDetailsLinks[network]) { return transactionDetailsLinks[network] + hash } -} \ No newline at end of file +} + +/** + * Get the block scout url for a given chain id and tx hash + * @param chainId - The chain id + * @param txHash - The tx hash + * @returns The block scout url + */ +export async function getBlockScoutUrl(chainId: number, txHash: string) { + const chain = await fetch('https://raw.githubusercontent.com/blockscout/chainscout/refs/heads/main/data/chains.json') + const response = await chain.json() + const data = response[chainId] + return data ? `${data.explorers[0].url}/tx/${txHash}` : null +}