Prompt users to sign transactions and broadcast them to the Stacks blockchain.
The process of broadcasting transactions is fundamental for interacting with blockchains, whether you're transferring tokens, deploying contracts, or executing contract functions.
Users must authenticate to an app before prompting them to sign and broadcast transactions to the Stacks blockchain with an authenticator such as the Leather wallet.
There are three types of transactions: STX transfers, contract deployments, and contract executions.
To prompt the user to transfer STX, call the openSTXTransfer function provided by the @stacks/connect package to trigger the display of a transaction signing prompt for transferring STX:
Several parameters are available for calling openSTXTransfer. To learn more, check out our reference page.
Each transaction signing method from @stacks/connect allows you to specify an onFinish callback. This callback will be triggered after the user has successfully broadcasted their transaction. The transaction will be broadcasted, but it will be pending until it has been mined on the Stacks blockchain.
You can access some information about this transaction via the arguments passed to onFinish. Your callback will be fired with a single argument, which is an object with the following properties:
The StacksTransaction type comes from the @stacks/transactions library.
The txId property can be used to provide a link to view the transaction in the explorer.
All of the methods included on this page accept a network option. By default, Connect uses a testnet network option. You can import a network configuration from the @stacks/network package.