The OKX Injected Providers API (Signet) is based on a JavaScript model embedded by OKX into user-accessed websites. DApp projects can use this API to request your account information, read data from the blockchain to which you are connected, and help you in signing messages and transactions.
okxwallet.bitcoinSignet.connect()
Description
Connect wallet
Parameters
none
Return value
Example
const result = await okxwallet.bitcoinSignet.connect()
// example
{
address: 'bc1pwqye6x35g2n6xpwalywhpsvsu39k3l6086cvdgqazlw9mz2meansz9knaq',
publicKey: '4a627f388196639041ce226c0229560127ef9a5a39d4885123cd82dc82d8b497'
}
okxwallet.bitcoinSignet.signMessage(signStr[, type])
Description
Sign message
Parameters
Return value
Example
const signStr = 'need sign string';
const result = await window.okxwallet.bitcoinSignet.signMessage(signStr, 'ecdsa')
// example
INg2ZeG8b6GsiYLiWeQQpvmfFHqCt3zC6ocdlN9ZRQLhSFZdGhgYWF8ipar1wqJtYufxzSYiZm5kdlAcnxgZWQU=
okxwallet.bitcoinSignet.signPsbt(psbtHex[, options])
Description
Signing psbt: this will traverse all inputs that match the current address to sign.
Parameters
When you generate the psbt (string) to be signed, you need to add a public key for every input of the psbt if the input uses a Taproot address.
Example: Refer to txInput and publicKey below.
const txInputs: utxoInput[] = [];
txInputs.push({
txId: "1e0f92720ef34ab75eefc5d691b551fb2f783eac61503a69cdf63eb7305d2306",
vOut: 2,
amount: 341474,
address: "tb1q8h8....mjxzny",
privateKey: "0s79......ldjejke",
publicKey: "tb1q8h8....mjxzny",
bip32Derivation: [
{
"masterFingerprint": "a22e8e32",
"pubkey": "tb1q8h8....mjxzny",
"path": "m/49'/0'/0'/0/0",
},
],
});
Return value
Example
try {
let res = await okxwallet.bitcoinSignet.signPsbt('70736274ff01007d....', {
autoFinalized: false,
toSignInputs: [
{
index: 0,
address: 'tb1q8h8....mjxzny',
},
{
index: 1,
publicKey: 'tb1q8h8....mjxzny',
sighashTypes: [1],
},
{
index: 2,
publicKey: '02062...8779693f',
},
],
});
console.log(res);
} catch (e) {
console.log(e);
}
okxwallet.bitcoinSignet.signPsbt('xxxxxxxx', {
toSignInputs: [{ index: 0, publicKey: 'xxxxxx', disableTweakSigner: true }],
autoFinalized: false,
});
okxwallet.bitcoinSignet.signPsbts(psbtHexs[, options])
Description
Signing psbts: this will traverse all inputs that match the current address to sign.
Parameters
When you generate the psbt (string) to be signed, you need to add a public key for every input of the psbt if the input uses a Taproot address.
Example: Refer to txInput and publicKey below.
const txInputs: utxoInput[] = [];
txInputs.push({
txId: "1e0f92720ef34ab75eefc5d691b551fb2f783eac61503a69cdf63eb7305d2306",
vOut: 2,
amount: 341474,
address: "tb1q8h8....mjxzny",
privateKey: "0s79......ldjejke",
publicKey: "tb1q8h8....mjxzny",
bip32Derivation: [
{
"masterFingerprint": "a22e8e32",
"pubkey": "tb1q8h8....mjxzny",
"path": "m/49'/0'/0'/0/0",
},
],
});
Return value
Example
try {
let res = await okxwallet.bitcoinSignet.signPsbts([
'70736274ff01007d...',
'70736274ff01007d...',
]);
console.log(res);
} catch (e) {
console.log(e);
}