Skip to content

useTransferBTC

Creates a Bitcoin transaction to transfer BTC to one or more recipients using the configured wallet. The transaction will only be broadcast if publish is set to true in the parameters.

Import

ts
import { useTransferBTC } from '@midl/react';

Example

tsx
function MyComponent() {
    const { transferBTC } = useTransferBTC();

    return (
        <button onClick={() => transferBTC({
            transfers: [
                {
                    amount: 100000,
                    receiver: 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq'
                }
            ],
            publish: true // Set to true to broadcast the transaction
        })}>Transfer 0.1 BTC</button>
    );
}

Parameters

NameTypeDescription
mutationUseMutationOptions(optional) Mutation options for react-query.
configConfig(optional) Custom config to override the default from context.

TransferBTCVariables

See TransferBTCParams for the full list of parameters.

Returns

NameTypeDescription
transferBTC(variables: TransferBTCVariables) => voidFunction to initiate a BTC transfer.
transferBTCAsync(variables: TransferBTCVariables) => Promise<TransferBTCData>Function to asynchronously transfer BTC.
...restobjectAdditional mutation state (e.g. isLoading, error, etc.).