useSendTransactionWithSession
Import
import { useSendTransactionWithSession } from '@zerodev/waas'Usage
import { useSendTransactionWithSession } from '@zerodev/waas';
function App() {
const { write } = useSendTransactionWithSession();
return (
<button
onClick={() =>
write([
{
to: TO_ADDRESS,
value: VALUE,
data: DATA
}
])
}
>
Send Transactions With Session
</button>
)
}Parameters
import { type UseSendTransactionWithSessionParameters } from '@zerodev/waas';sessionId
0x${tring}
The sessionId of session used to send user operation
paymaster
{type: "SPONSOR"} | {type: "ERC20", gasToken: string} | undefined
The paymaster type and gas token address.
-
type
SPONSOR | ERC20The type of paymaster. -
gasToken
string | undefinedThe symbol of erc20 token used for erc20 paymaster.
isParallel
boolean | undefined
- Default to
True - The flag determine whether the user operation allows parallel execution.
nonceKey
string | undefined
The key to generate nonce for userop.
Return Types
import { type UseSendTransactionWithSessionReturnType } from '@zerodev/waas'write
(variables: SendTransactionWithSessionVariables) => void
The mutation function to send transactions with session.
-
variables
-
to
AddressThe contract's address. -
value
bigint | undefinedValue in wei sent with this transaction. -
data
Hex | undefinedData sent with this transaction.
-
writeAsync
(variables: SendTransactionWithSessionVariables) => Promise<SendTransactionWithSessionData>
Similar to write but returns a promise.
-
variables
-
to
AddressThe contract's address. -
value
bigint | undefinedValue in wei sent with this transaction. -
data
Hex | undefinedData sent with this transaction.
-
data
Hash | undefined
- Defaults to
undefined - The last successfully resolved data for the mutation.
error
Error | null
The error object for the mutation, if an error was encountered.
isError / isIdle / isPending / isSuccess
boolean
Boolean variables derived from status.
isPaused
boolean
- will be
trueif the mutation has beenpaused. - see Network Mode for more information.
status
'idle' | 'pending' | 'error' | 'success'
'idle'initial status prior to the mutation function executing.'pending'if the mutation is currently executing.'error'if the last mutation attempt resulted in an error.'success'if the last mutation attempt was successful.
reset
() => void
A function to clean the mutation internal state (e.g. it resets the mutation to its initial state).