useSendPermission
This hook handles the process of sending permissions and monitors the transaction’s status.
Returns:
Usage Example:
import { useSendPermission } from "path/to/hook";
const Component = () => {
const {
data,
error,
isPending,
isSuccess,
isError,
sendPermission,
sendPermissionAsync,
} = useSendPermission({
sessionData: ...,
privateKey: ...,
});
const handleSendPermission = () => {
sendPermission({
actions: [
{
target: 0x012345...",
callData: "0x012345...",
value: BigInt(0),
},
],
});
};
const handleAsyncSendPermission = async () => {
try {
const txHash = await sendPermissionAsync({
actions: [
{
target: 0x012345...",
callData: "0x012345...",
value: BigInt(0),
},
],
});
console.log("Transaction hash:", txHash);
} catch (err) {
console.error("Permission sending failed:", err);
}
};
return (
<div>
{isPending && <p>Sending permission...</p>}
{isSuccess && <p>Permission sent successfully!</p>}
{isError && <p>Error: {error?.message}</p>}
<button onClick={handleSendPermission}>Send Permission</button>
<button onClick={handleAsyncSendPermission}>Send Permission (Async)</button>
</div>
);
};How It Works:
Example of Expected Response:
Error Handling:
Mutation Props (mutationProps):
Last updated