Bitcoin Dapp Integration
This API is designed for DApps opened within the Tokeo wallet browser. When users navigate to your site from the in-app browser, window.tokeo.bitcoin
is automatically injected to allow seamless interaction.
If youβre building a mobile DApp or want to integrate outside of the Tokeo browser, our wallet also supports deep linking. You can find details here.
π§© Overview
DApps can use window.tokeo.bitcoin
to:
Request access to user accounts
Sign messages
Sign transactions
All responses are returned directly, and methods are either synchronous or return Promises depending on the implementation.
π API Methods
window.tokeo.bitcoin.requestAccounts(): Promise<object[]>
window.tokeo.bitcoin.requestAccounts(): Promise<object[]>
Returns a list of addresses the DApp is authorized to use.
Example Response:
[{
"address": "bc1pabc123...",
"type": "p2tr",
"network": "mainnet",
"publicKey": "abcdef1234567890..." // 64-character hex (x-only Taproot pubkey)
}]
window.tokeo.bitcoin.getAccounts(): object[]
window.tokeo.bitcoin.getAccounts(): object[]
Returns the same list as requestAccounts()
but without the user prompt (if already enabled).
window.tokeo.bitcoin.signMessage(message: string, type: 'ecdsa' | 'bip322'): Promise<string>
window.tokeo.bitcoin.signMessage(message: string, type: 'ecdsa' | 'bip322'): Promise<string>
Signs an arbitrary message using the selected Bitcoin key.
Parameters:
message
: string β the message to signtype
:'ecdsa'
or'bip322'
(default is'ecdsa'
)
Returns: signature string
window.tokeo.bitcoin.signPsbt(psbt: string, options?: object): Promise<string>
window.tokeo.bitcoin.signPsbt(psbt: string, options?: object): Promise<string>
Signs a PSBT transaction.
Parameters:
psbt
: base64-encoded PSBT stringoptions
: object (optional)autoFinalize
: boolean β whether to finalize the PSBT after signing (default: true)inputs
: array of objects (optional per-input overrides)-
index
: number β index of the input-
address
: string β inputβs associated address-
publicKey
: string β inputβs public key-
sighashTypes
: number[] β array of sighash types (e.g. [1] for SIGHASH_ALL)-
disableTweakSigner
: boolean β disables Taproot tweak signing-
useTweakedSigner
: boolean β forces tweaked signer usage
Returns: base64-encoded signed PSBT
π Permissions Model
Wallet prompts users once per session for requestAccounts()
.
After that, other read methods (like getAccounts
) donβt prompt again unless session is reset.
π§ͺ Example Usage
const accounts = await window.tokeo.bitcoin.requestAccounts();
const signature = await window.tokeo.bitcoin.signMessage("hello", "ecdsa");
β Error Handling
Errors are thrown as JavaScript exceptions.
You can catch them with:
try {
await window.tokeo.bitcoin.requestAccounts();
} catch (e) {
console.error("User rejected connection", e);
}
π§ Notes
No base64-encoded
data
parameter is required.If youβre building a mobile DApp or want to integrate outside of the browser context, our wallet also supports deep linking. You can find details here.
Last updated