Methods

requestAccounts

Description

Connects to the user’s Phantom account.

Parameters

None

Response

Promise<BtcAccount[]>
array

Array of the connected user’s BtcAccount objects.

BtcAccount response object properties

address
string

The Bitcoin address owned by the user.

addressType
p2tr, p2wpkh, p2sh, p2pkh

The address’s format. For details, see Bitcoin Design Glossary.

publicKey
string

A hex string representing the bytes of the public key of the account.

purpose
payment, ordinals

The general purpose of the address. If ordinals, the user prefers to store Ordinals on this address. If payment, the user prefers to store Bitcoin on this address.

signMessage

Description

Signs a message with the user’s Phantom account.

Parameters

message
Uint8array

The message to be signed.

address
string

One of the user’s addresses that should be used to sign the message.

Response

Promise<{ signature: Uint8Array; }>
object

Object containing the signature.

signPSBT

Description

Signs a Partially-Signed Bitcoin Transaction (PSBT).

Parameters

psbtHex
Uint8Array

A serialized PSBT.

options
object

Configuration options for signing the PSBT.

options parameters

An array containing the indexes of which transaction inputs to sign, and how to sign them.

Response

Promise<string>
string

A serialized PSBT where the inputs belonging to the user’s account have been signed.

Events

accountsChanged

Description

The event that is emitted when a user changes their connected Phantom account.

type AccountsChangedEvent = (accounts: BtcAccount[]) => void;

Properties

accounts
BtcAccount[]

The array of BtcAccount objects of the newly connect Phantom account.

BtcAccount response object properties

address
string

The Bitcoin address owned by the user.

addressType
p2tr, p2wpkh, p2sh, p2pkh

The address’s format. For details, see Bitcoin Design Glossary.

publicKey
string

A hex string representing the bytes of the public key of the account.

purpose
payment, ordinals

The general purpose of the address. If ordinals, the user prefers to store Ordinals on this address. If payment, the user prefers to store Bitcoin on this address.