Mutation hook for signing and broadcasting Cosmos transactions using a CosmJS signer and signing client.
Requires @getpara/cosmjs-v0-integration and @cosmjs/stargate as peer dependencies.
Import
import { useParaCosmjsSignAndBroadcast } from "@getpara/react-native-wallet/cosmos";
Usage
import { useParaCosmjsProtoSigner, useParaCosmjsSignAndBroadcast } from "@getpara/react-native-wallet/cosmos";
import { SigningStargateClient, coins } from "@cosmjs/stargate";
function SendTokens() {
const { protoSigner } = useParaCosmjsProtoSigner();
// Connect signing client (see useParaCosmjsProtoSigner docs)
const { signAndBroadcastAsync, isPending } = useParaCosmjsSignAndBroadcast(protoSigner, client);
const handleSend = async () => {
const result = await signAndBroadcastAsync({
messages: [sendMsg],
fee: { amount: coins(5000, "uatom"), gas: "200000" },
});
console.log("Tx hash:", result.transactionHash);
};
return (
<button onClick={handleSend} disabled={isPending}>
{isPending ? "Broadcasting..." : "Send Tokens"}
</button>
);
}
mutate/mutateAsync are also available alongside the named aliases. All other UseMutationResult fields (data, error, isSuccess, isError, reset, etc.) work as expected.