Skip to main content
In this example, we are going to sign a PBST with a Bitcoin wallet.
  • React
  • JavaScript
  import { 
    type BitcoinSignPsbtRequest,
    isBitcoinWallet, 
  } from '@dynamic-labs/bitcoin';

  // the wallet object is the wallet you want to send from
  // you can access the available wallets via the `useUserWallets` hook
  // or get the primaryWallet via the `useDynamicContext` hook
  const SignPsbtButton = ({ wallet }) => {
    const onSignPsbt = async () => {
      if (!isBitcoinWallet(wallet)) {
        return;
      }

      const request: BitcoinSignPsbtRequest = {
        // The PSBT request to sign
      };

      const { signedPsbt } = await wallet.signPsbt(request);

      console.log('signedPsbt', signedPsbt);
    };

    return <button onClick={onSignPsbt}>Sign PSBT</button>;
  };
You can also sign multiple PSBTs at once, as shown below:
  • React
  • JavaScript
  import { 
    type BitcoinSignPsbtRequest,
    isBitcoinWallet, 
  } from '@dynamic-labs/bitcoin';

  // the wallet object is the wallet you want to send from
  // you can access the available wallets via the `useUserWallets` hook
  // or get the primaryWallet via the `useDynamicContext` hook
  const SignPsbtsButton = ({ wallet }) => {
    const onSignPsbts = async () => {
      if (!isBitcoinWallet(wallet)) {
        return;
      }

      const requests: BitcoinSignPsbtRequest[] = [
        // The list of PSBT requests to sign
      ];

      const signedPsbts = await wallet.signPsbts(requests);

      console.log('signedPsbts', signedPsbts);
    };

    return <button onClick={onSignPsbts}>Sign PSBTs</button>;
  };
You can see an example of how to create PSBTs for testing in the Create a PSBT guide.