Skip to main content

Import

import { useSendWalletTransaction } from '@0xsequence/connect'

Usage

import { useSendWalletTransaction } from '@0xsequence/connect'

function App() {
  const {
    sendTransactionAsync,
    isLoading,
    error,
    data,
    reset
  } = useSendWalletTransaction()

  const send = async () => {
    const hash = await sendTransactionAsync({
      chainId: 42161,
      transaction: {
        to: '0x0000000000000000000000000000000000000000',
        data: '0x'
      }
    })
    console.log('tx hash', hash)
  }

  return (
    <div>
      <button onClick={send}>Send via wallet popup</button>
      {isLoading && <div>Sending...</div>}
      {error && <div>Error: {error.message}</div>}
      {data && <div>Hash: {data}</div>}
      <button onClick={reset}>Reset</button>
    </div>
  )
}

Parameters

type SendWalletTransactionParams = {
  chainId: number
  transaction: TransactionRequest
}

Return Type

type UseSendWalletTransactionReturnType = {
  isLoading: boolean
  error: Error | null
  data: string | undefined
  sendTransaction: (params: SendWalletTransactionParams) => void
  sendTransactionAsync: (params: SendWalletTransactionParams) => Promise<string>
  reset: () => void
}

Notes

  • This hook uses the Sequence V3 connector and opens the wallet popup for user approval.
  • transaction.to is required.