- Create an unsigned transaction.
- Have the transaction be signed and submitted to the network by the user’s Phantom wallet.
- Optionally await network confirmation using a Solana JSON RPC connection.
For more information about the nature of Solana transactions, refer to the solana-web3.js documentation and the Solana Cookbook.
Sign and send a transaction
Once a transaction is created, the web application may ask the user’s Phantom wallet to sign and send the transaction. If accepted, Phantom will sign the transaction with the user’s private key and submit it via a Solana JSON RPC connection. By far the easiest and most recommended way of doing this is by using thesignAndSendTransaction
method on the provider, but it is also possible to do with request
. In both cases, the call will return a Promise for an object containing the signature
.
signAndSendTransaction()
request()
SendOptions
object as a second argument into signAndSendTransaction
or as an options
parameter when using request
.
For a live demo of signAndSendTransaction
, refer to handleSignAndSendTransaction in our sandbox.
Sign and send multiple transactions
It is also possible to sign and send multiple transactions at once. This is exposed through thesignAndSendAllTransactions
method on the provider. This method accepts an array of Solana transactions, and will optionally accept a SendOptions object as a second parameter. If successful, it will return a Promise for an object containing the array of string signatures
and the publicKey
of the signer.
signAndSendAllTransactions()
Other signing methods
The following methods are also supported, but are not recommended oversignAndSendTransaction
. It is safer for users, and a simpler API for developers, for Phantom to submit the transaction immediately after signing it instead of relying on the application to do so.
The following methods are not supported in the wallet standard implementation and may be removed in a future release. These methods are only available via the window.solana object.
Sign a transaction (without sending)
Once a transaction is created, a web application may ask the user’s Phantom wallet to sign the transaction without also submitting it to the network. The easiest and most recommended way of doing this is via thesignTransaction
method on the provider, but it is also possible to do via request
. In both cases, the call will return a Promise for the signed transaction. After the transaction has been signed, an application may submit the transaction itself using sendRawTransaction in web3.js.
signTransaction()
request()
signTransaction
, refer to handleSignTransaction in our sandbox.
Sign multiple transactions
For legacy integrations, Phantom supports signing multiple transactions at once without sending them. This is exposed through thesignAllTransactions
method on the provider. This method is not recommended for new integrations. Instead, developers should make use of signAndSendAllTransactions
.
signAllTransactions()
request()
signAllTransactions
, refer to handleSignAllTransactions in our sandbox.