インポート
import { useCheckWaasFeeOptions } from '@0xsequence/connect'
使い方
import { useCheckWaasFeeOptions } from '@0xsequence/connect'
function App() {
const checkFeeOptions = useCheckWaasFeeOptions()
const handleTransaction = async () => {
// Example transaction
const transaction = {
to: '0x...',
value: '1000000000000000000', // 1 ETH
data: '0x...'
}
const { isSponsored, feeOptions, feeQuote } = await checkFeeOptions({
transactions: [transaction],
chainId: 1 // Ethereum Mainnet
})
if (isSponsored) {
console.log('Transaction is sponsored!')
} else if (feeOptions) {
console.log('Available fee options:', feeOptions)
console.log('Fee quote:', feeQuote)
// Handle fee payment selection
}
}
return (
<div>
<button onClick={handleTransaction}>
Check Transaction Fees
</button>
</div>
)
}
返り値の型
このフックは、以下のシグネチャを持つ関数を返します:
(params: {
transactions: Transaction[]
chainId: number
}) => Promise<{
feeQuote: string | undefined
feeOptions: FeeOption[] | undefined
isSponsored: boolean
}>
パラメータ
transactions
Transaction[]
手数料オプションを確認したいトランザクションの配列です。
interface Transaction {
to: string
value?: string
data?: string
// ... other transaction properties
}
chainId
number
トランザクションが実行されるブロックチェーンネットワークのIDです。
返り値オブジェクトのプロパティ
boolean
トランザクションがスポンサー付き(true)か、手数料支払いが必要(false)かを示します。
feeOptions
FeeOption[] | undefined
トランザクションがスポンサー付きでない場合に利用可能な手数料支払いオプションです。
interface FeeOption {
token: {
symbol: string
decimals: number
address: string
}
// ... other fee option properties
}
feeQuote
string | undefined
利用可能な場合のトランザクションの手数料見積もりです。
このフックは、Sequence WaaS(Wallet as a Service)専用で、以下の機能を提供します:
- トランザクションがスポンサー付きかどうかを確認
- スポンサー付きでない場合の利用可能な手数料オプションを取得
- トランザクションの手数料見積もりを取得