Skip to main content

useMutation

Callable

  • useMutation<TAction, TChainId>(action: TAction, options?: ChainHookOptions<TChainId> & { signer?: PolkadotSigner; txOptions?: Partial<void extends ReturnType<TAction> extends Transaction<_Args, _Pallet, _Tx, Asset> ? Asset : void ? {} : {}> }): [state: AsyncValue<Value, MutationError>, execute: (...args: [submitOptions?: Partial<void extends ReturnType<TAction> extends Transaction<_Args, _Pallet, _Tx, Asset> ? Asset : void ? {} : {}> & { signer?: PolkadotSigner }]) => Promise<void> | Subscription]

  • Hook for sending transactions to chains.


    Type parameters

    • TAction: (builder: any) => Transaction<any, any, any, any>
    • TChainId: any

    Parameters

    • action: TAction

      The function to create the transaction

    • optionaloptions: ChainHookOptions<TChainId> & { signer?: PolkadotSigner; txOptions?: Partial<void extends ReturnType<TAction> extends Transaction<_Args, _Pallet, _Tx, Asset> ? Asset : void ? {} : {}> }

      Additional options

    Returns [state: AsyncValue<Value, MutationError>, execute: (...args: [submitOptions?: Partial<void extends ReturnType<TAction> extends Transaction<_Args, _Pallet, _Tx, Asset> ? Asset : void ? {} : {}> & { signer?: PolkadotSigner }]) => Promise<void> | Subscription]

    The current transaction state & submit function