Methods

requestAccounts

Connect the current account

Requests

cactuslink.requestAccounts()

Parameter

None

Returns

  • Promise - string[]: Address of current account

Example

try {
    let accounts = await window.cactuslink.requestAccounts();
    console.log('connected to', accounts);
} catch (e) {
    console.log('connection failed');
}

> connected to ['1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1']

getAccounts

Get address of current account

Requests

cactuslink.getAccounts()

Parameter

None

Returns

  • Promise - string[]: address of current account

Example

try {
    let res = await window.cactuslink.getAccounts();
    console.log(res)
} catch (e) {
    console.log(e);
}

> ['1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1']

getNetwork

Get the network of the current account

Requests

cactuslink.getNetwork()

Parameter

None

Returns

  • Promise - string: the network types include mainnet, signet or testnet

Example

try {
    let res = await window.cactuslink.getNetwork();
    console.log(res)
} catch (e) {
    console.log(e);
}

> 0

switchNetwork

switch the network

Requests

cactuslink.switchNetwork(network)

Parameter

  • network - string: the network to be switched, the network types include mainnet, signet or testnet

Returns

None

Example

try {
    let res = await window.cactuslink.switchNetwork("testnet");
    console.log(res)
} catch (e) {
    console.log(e);
}

> 0

getPublicKey

Get publicKey of current account

Requests

cactuslink.getPublicKey()

Parameter

None

Returns

  • Promise - string: publicKey

Example

try {
  let res = await window.cactuslink.getPublicKey();
  console.log(res)
} catch (e) {
  console.log(e);
}

> 03cbaedc26f03fd3ba02fc936f338e980c9e2172c5e23128877ed46827e935296f

getBalance

Get BTC balance of the current account

Requests

cactuslink.getBalance()

Parameter

None

Returns

  • Promise - Object:
    • confirmed - number: the confirmed satoshis
    • unconfirmed - number: the unconfirmed satoshis
    • total - number: the total satoshis

Example

try {
  let res = await window.cactuslink.getBalance();
  console.log(res)
} catch (e) {
  console.log(e);
}

> {
    "confirmed": 0,
    "unconfirmed": 100000,
    "total": 100000
  }

getBitcoinUtxos

List UTXOs of the current account

Requests

cactuslink.getBitcoinUtxos(cursor,size)

Parameter

  • cursor - number: (optional) offset starting from 0, the default value is 0
  • size - number: (optional) number per page, the default value is 20

Returns

  • Promise - Object:
    • txid - string: the transaction hash
    • vout - number: the index of the specific output
    • satoshis - number: the amount of satoshis in this output
    • srciptPk - string: the locking script associated with the output
    • adressType - number: 0 for Native Segwit (P2WPKH), 2 for Taproot (P2TR)
    • pubkey - string: the public key associated with this output for ownership verification

Example

try {
  let res = await window.cactuslink.getBitcoinUtxos(0,10);
  console.log(res)
} catch (e) {
  console.log(e);
}

> [{
    "txid": "05c467f65af589dc0636a31f52093a1afa3940ce509c13ad3390ecfb4c710b05",
    "vout": 1,
    "satoshis": 5554937,
    "scriptPk": "0014144ce0ac011060e140fc0a2202e94b59afe71f80",
    "addressType": 1,
    "pubkey": "02c7ac587ec0024b0bc78c2aea04a1339f0d4038e712b8516215879989d574aea9"
  }]

signMessage

Verify the holder via a signed message

Requests

cactuslink.signMessage(msg[, type])

Parameter

  • msg - string: a string to sign
  • type - string: (optional) "ecdsa" (other types are not supported yet like bip322-simple)

Returns

Promise - string: the signature

Example

// sign by ecdsa
try {
 let res = await window.cactuslink.signMessage("abcdefghijk123456789");
 console.log(res)
} catch (e) {
 console.log(e);
}

> G+LrYa7T5dUMDgQduAErw+i6ebK4GqTXYVWIDM+snYk7Yc6LdPitmaqM6j+iJOeID1CsMXOJFpVopvPiHBdulkE=

pushTx

Push the transactions

Requests

cactuslink.pushTx(options)

Parameter

  • options - Object:
    • rawtx - string: raw transactions to push

Returns

  • Promise - string: txid

Example

try {
  let txid = await window.cactuslink.pushTx({
    rawtx:"0200000000010135bd7d..."
  });
  console.log(txid)
} catch (e) {
  console.log(e);
}

signPsbt

Traverse all inputs that match the current address to sign

Requests

cactuslink.signPsbt(psbtHex[, options])

Parameter

  • psbtHex - string: the hex string of PSBT to sign
  • options *autoFinalized - boolean: whether finalize PSBT after signing, default is true

Returns

  • Promise - string: the hex string of signed PSBT

Example

try {
  let res = await window.cactuslink.signPsbt("70736274ff01007d....");
  console.log(res)
} catch (e) {
  console.log(e);
}

cactuslink.signPsbt("xxxxxxxx", {autoFinalized:false})

pushPsbt

Push PSBT transactions

Requests

cactuslink.pushPsbt(psbtHex)

Parameter

  • psbtHex - string: the hex string of PSBT to push

Returns

  • Promise - string: txid

Example

try {
  let res = await window.cactuslink.pushPsbt("70736274ff01007d....");
  console.log(res)
} catch (e) {
  console.log(e);
}
Copyright © 2025 Cactus Custody all right reserved,powered by GitbookUpdated: 10-Sep-2025 03:20:52

results matching ""

    No results matching ""

    results matching ""

      No results matching ""