@@ -6,11 +6,13 @@ import { ContractWriteMethods } from "./ContractWriteMethods";
6
6
import { AbiFunction } from "abitype" ;
7
7
import { Abi , Address as AddressType } from "viem" ;
8
8
import { useContractRead } from "wagmi" ;
9
+ import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline" ;
9
10
import { MiniFooter } from "~~/components/MiniFooter" ;
10
11
import { Address , Balance , MethodSelector } from "~~/components/scaffold-eth" ;
11
12
import { useNetworkColor } from "~~/hooks/scaffold-eth" ;
13
+ import useFetchContractCreationInfo from "~~/hooks/useFetchContractCreationInfo" ;
12
14
import { useGlobalState } from "~~/services/store/store" ;
13
- import { getTargetNetworks } from "~~/utils/scaffold-eth" ;
15
+ import { getBlockExplorerTxLink , getTargetNetworks } from "~~/utils/scaffold-eth" ;
14
16
15
17
type ContractUIProps = {
16
18
className ?: string ;
@@ -70,6 +72,11 @@ export const ContractUI = ({ className = "", initialContractData }: ContractUIPr
70
72
const router = useRouter ( ) ;
71
73
const { network } = router . query as { network ?: string } ;
72
74
75
+ const { contractCreationInfo, isLoading : isContractCreationLoading } = useFetchContractCreationInfo ( {
76
+ contractAddress : initialContractData . address ,
77
+ chainId,
78
+ } ) ;
79
+
73
80
const updateUrlWithSelectedMethods = ( selectedMethods : string [ ] ) => {
74
81
const currentQuery = new URLSearchParams ( window . location . search ) ;
75
82
if ( selectedMethods . length > 0 ) {
@@ -220,6 +227,28 @@ export const ContractUI = ({ className = "", initialContractData }: ContractUIPr
220
227
</ span >
221
228
</ p >
222
229
) }
230
+ { ! isContractCreationLoading && contractCreationInfo && (
231
+ < div className = "my-0 text-sm flex items-center gap-2" >
232
+ < span className = "font-bold" > Created at:</ span >
233
+ { isContractCreationLoading ? (
234
+ < span className = "loading loading-spinner loading-xs" > </ span >
235
+ ) : (
236
+ contractCreationInfo && (
237
+ < >
238
+ < span > Block { contractCreationInfo . blockNumber } </ span >
239
+ < a
240
+ href = { getBlockExplorerTxLink ( chainId , contractCreationInfo . txHash ) }
241
+ target = "_blank"
242
+ rel = "noopener noreferrer"
243
+ className = "link no-underline"
244
+ >
245
+ < ArrowTopRightOnSquareIcon className = "w-4 h-4" />
246
+ </ a >
247
+ </ >
248
+ )
249
+ ) }
250
+ </ div >
251
+ ) }
223
252
</ div >
224
253
< div className = "bg-base-200 shadow-xl rounded-2xl px-6 py-4" >
225
254
< span className = "block font-bold pb-3" > Contract Data</ span >
0 commit comments