@@ -15,10 +15,13 @@ import {
1515import { useState } from "react" ;
1616import { toast } from "sonner" ;
1717import type { ThirdwebClient } from "thirdweb" ;
18+ import { sendTransaction } from "thirdweb" ;
1819import { useActiveAccount } from "thirdweb/react" ;
1920import type { Account } from "thirdweb/wallets" ;
21+ import { getThirdwebClient } from "../../../../@/constants/thirdweb.server" ;
2022import { TransactionButton } from "../../../../components/buttons/TransactionButton" ;
2123import { MarkdownRenderer } from "../../../../components/contract-components/published-contract/markdown-renderer" ;
24+ import { useV5DashboardChain } from "../../../../lib/v5-adapter" ;
2225import { submitFeedback } from "../api/feedback" ;
2326import { NebulaIcon } from "../icons/NebulaIcon" ;
2427
@@ -241,16 +244,28 @@ function SendTransactionButton(props: {
241244 twAccount : TWAccount ;
242245} ) {
243246 const account = useActiveAccount ( ) ;
247+ const chain = useV5DashboardChain ( props . txData ?. chainId ) ;
248+
244249 const sendTxMutation = useMutation ( {
245250 mutationFn : ( ) => {
246251 if ( ! account ) {
247252 throw new Error ( "No active account" ) ;
248253 }
249254
250- if ( ! props . txData ) {
255+ if ( ! props . txData || ! chain ) {
251256 throw new Error ( "Invalid transaction" ) ;
252257 }
253- return account . sendTransaction ( props . txData ) ;
258+
259+ return sendTransaction ( {
260+ account,
261+ transaction : {
262+ ...props . txData ,
263+ nonce : Number ( props . txData . nonce ) ,
264+ to : props . txData . to || undefined , // Get rid of the potential null value
265+ chain,
266+ client : getThirdwebClient ( ) ,
267+ } ,
268+ } ) ;
254269 } ,
255270 } ) ;
256271
0 commit comments