Provider API

The Oyl Connect Provider API allows DApps to interact with the Oyl wallet, enabling them to request account information, sign messages and transactions, and broadcast transactions to the network.

isConnected

Used to check if the current site origin is connected to the wallet.

Response

  • boolean

Example

try {
  const response = await window.oyl.isConnected()
} catch (e) {
 // Handle error (E.g. OylConnectError)
}

disconnect

Used to disconnect the current site origin from the wallet.

Example

try {
  await window.oyl.disconnect()
} catch (e) {
 // Handle error (E.g. OylConnectError)
}

getAddresses

Returns all the addresses and the public keys of the current account.

Params

None

Response

  • Promise - object

    • taproot - object

      • address - string

      • publicKey - string

    • nativeSegwit - object

      • address - string

      • publicKey - string

    • nestedSegwit - object

      • address - string

      • publicKey - string

    • legacy

      • address - string

      • publicKey - string

Example

try {
  const addresses = await window.oyl.getAddresses()
} catch (e) {
 // Handle error (E.g. OylConnectError)
}

getBalance

Returns the balance of all the addresses of the current account.

Params

None

Response

  • Promise - object

    • confirmed - number: confirmed amount in sats

    • unconfirmed - number: unconfirmed amount in sats

    • total - number: total amount in sats

Example

try {
  const response = await window.oyl.getBalance()
} catch (e) {
 // Handle error (E.g. OylConnectError)
}

signMessage

Sign a message using BIP322 or ECDSA

Params

  • Object

    • address - string: address to be used for signing

    • message - string: message to be signed

    • protocol - string (optional) "bip322" | "ecdsa": the protocol to be used for signing — the default value is "bip322".

Response

  • Promise - object

    • address - string: address used to sign the message

    • signature - string: signing result

Example

try {
  const response = await window.oyl.signMessage({ 
    address: "bc1p...",  
    message: "I need a signature."
  })
} catch (e) {
 // Handle error (E.g. OylConnectError)
}

signPsbt

Sign a partially signed bitcoin transaction (PSBT).

This method will use all the addresses of the current account to sign the inputs.

Params

  • Object

    • psbt - string: hexadecimal representation of the partially signed bitcoin transaction (PSBT) to be signed

    • finalize - boolean (optional): whether to finalize the PSBT after signing — the default is true

    • broadcast - boolean (optional): whether to broadcast the transaction after signing — the default is false

Response

  • Promise - object

    • psbt - string: hexadecimal representation of the signed PSBT

    • txid - string (optional): ID of the transaction that was broadcasted if the broadcast option was enabled

Example

try {
  const response = await window.oyl.signPsbt({ 
    psbt: "psbt hex",  
    broadcast: true
  })
} catch (e) {
 // Handle error (E.g. OylConnectError)
}

pushPsbt

Broadcast a signed PSBT transaction.

Params

  • Object

    • psbt - string: hexadecimal representation of the PSBT transaction to be broadcasted

Response

  • Promise - object

    • txid - string: ID of the transaction that was broadcasted

Example

try {
  const response = await window.oyl.pushPsbt({ 
    psbt: "psbt hex"
  })
} catch (e) {
 // Handle error (E.g. OylConnectError)
}

Last updated