@@ -88,7 +88,27 @@ export const RunButton = <ParameterName extends string>(
88
88
{ status . type === StatusType . Results && (
89
89
< div >
90
90
< h3 className = "mb-2 text-lg font-bold" > Results</ h3 >
91
- < Code language = "json" > { stringifyResponse ( status . data ) } </ Code >
91
+ { props . type === EvmApiType . Write &&
92
+ status . data &&
93
+ typeof status . data === "object" &&
94
+ "hash" in status . data &&
95
+ typeof status . data . hash === "string" ? (
96
+ < >
97
+ < p > { `Tx Hash: ${ status . data . hash } ` } </ p >
98
+ { "link" in status . data &&
99
+ typeof status . data . link === "string" && (
100
+ < InlineLink
101
+ href = { status . data . link }
102
+ target = "_blank"
103
+ className = "text-sm text-blue-500 hover:underline"
104
+ >
105
+ Open in explorer↗
106
+ </ InlineLink >
107
+ ) }
108
+ </ >
109
+ ) : (
110
+ < Code language = "json" > { stringifyResponse ( status . data ) } </ Code >
111
+ ) }
92
112
</ div >
93
113
) }
94
114
{ status . type === StatusType . Error && (
@@ -175,7 +195,17 @@ const useRunButton = <ParameterName extends string>({
175
195
} )
176
196
. then ( ( { request } ) => writeContract ( config , request ) )
177
197
. then ( ( result ) => {
178
- setStatus ( Results ( result ) ) ;
198
+ const explorer = config . chains . find (
199
+ ( chain ) => chain . id === config . state . chainId ,
200
+ ) ?. blockExplorers ?. default ;
201
+ setStatus (
202
+ Results ( {
203
+ hash : result ,
204
+ link : explorer
205
+ ? new URL ( `/tx/${ result } ` , explorer . url ) . toString ( )
206
+ : undefined ,
207
+ } ) ,
208
+ ) ;
179
209
} )
180
210
. catch ( ( error : unknown ) => {
181
211
setStatus ( ErrorStatus ( error ) ) ;
0 commit comments