diff --git a/apps/api-reference/src/components/EvmApi/run-button.tsx b/apps/api-reference/src/components/EvmApi/run-button.tsx index a721790064..3439fbc0e0 100644 --- a/apps/api-reference/src/components/EvmApi/run-button.tsx +++ b/apps/api-reference/src/components/EvmApi/run-button.tsx @@ -88,7 +88,27 @@ export const RunButton = ( {status.type === StatusType.Results && (

Results

- {stringifyResponse(status.data)} + {props.type === EvmApiType.Write && + status.data && + typeof status.data === "object" && + "hash" in status.data && + typeof status.data.hash === "string" ? ( + <> +

{`Tx Hash: ${status.data.hash}`}

+ {"link" in status.data && + typeof status.data.link === "string" && ( + + Open in explorer↗ + + )} + + ) : ( + {stringifyResponse(status.data)} + )}
)} {status.type === StatusType.Error && ( @@ -175,7 +195,17 @@ const useRunButton = ({ }) .then(({ request }) => writeContract(config, request)) .then((result) => { - setStatus(Results(result)); + const explorer = config.chains.find( + (chain) => chain.id === config.state.chainId, + )?.blockExplorers?.default; + setStatus( + Results({ + hash: result, + link: explorer + ? new URL(`/tx/${result}`, explorer.url).toString() + : undefined, + }), + ); }) .catch((error: unknown) => { setStatus(ErrorStatus(error));