MyDogeWallet

Class representing the MyDoge API to interact with the Dogecoin wallet.

Constructor

new MyDogeWallet()

Methods

(async) connect(onSuccessopt, onErroropt) → {Promise.<{approved: boolean, address: string, publicKey: string, balance: number}>}

Initiates a connection request with the wallet.
Parameters:
NameTypeAttributesDescription
onSuccessfunction<optional>
Optional callback function to execute upon successful connection. Receives an object containing the wallet address and balance.
onErrorfunction<optional>
Optional callback function to execute upon connection error.
Returns:
Promise object representing the outcome of the connection attempt, resolving to an object with the connected address information.
Type: 
Promise.<{approved: boolean, address: string, publicKey: string, balance: number}>
Example
connect(
  (result) => console.log(`Connected to wallet: ${result.address}`),
  (error) => console.error(`Connection failed: ${error}`)
).then(result => console.log(result.address))
  .catch(error => console.error(error));

(async) disconnect(onSuccessopt, onErroropt) → {Promise.<void>}

Disconnects the current session with the wallet.
Parameters:
NameTypeAttributesDescription
onSuccessfunction<optional>
Optional callback function to execute upon successful disconnection.
onErrorfunction<optional>
Optional callback function to execute upon error in disconnecting.
Returns:
Promise object representing the disconnection outcome.
Type: 
Promise.<void>
Example
disconnect(
  () => console.log(`Disconnected from wallet`),
  (error) => console.error(`Disconnection failed: ${error}`)
).then(() => console.log('Disconnected from wallet'))
  .catch(error => console.error(error));

(async) getBalance(onSuccessopt, onErroropt) → {Promise.<{address: string, balance: number}>}

Retrieves the balance from the connected wallet.
Parameters:
NameTypeAttributesDescription
onSuccessfunction<optional>
Optional callback function to execute upon successful retrieval of balance. Receives an object containing the wallet address and balance.
onErrorfunction<optional>
Optional callback function to execute upon error in retrieving balance.
Returns:
Promise object representing the outcome of the balance retrieval, resolving to an object with the wallet address and balance.
Type: 
Promise.<{address: string, balance: number}>
Example
getBalance(
  (result) => console.log(`Connected to wallet: ${result.balance}`),
  (error) => console.error(`Connection failed: ${error}`)
).then(result => console.log(result.balance))
  .catch(error => console.error(error));

(async) getConnectionStatus(onSuccessopt, onErroropt) → {Promise.<{connected: boolean, address: string, selectedWalletAddress: string}>}

Retrieves the connection status with the wallet.
Parameters:
NameTypeAttributesDescription
onSuccessfunction<optional>
Optional callback function to execute upon successfully retrieving the status. Receives an object containing the wallet address, selected wallet address, and connection status.
onErrorfunction<optional>
Optional callback function to execute upon error in retrieving the connection status.
Returns:
Promise object representing the outcome of the connection status retrieval, resolving to an object with the wallet address, selected wallet address, and connection status.
Type: 
Promise.<{connected: boolean, address: string, selectedWalletAddress: string}>
Example
getConnectionStatus(
  (result) => console.log(`Connected to wallet: ${result.connected}`),
  (error) => console.error(`Connection status retrieval failed: ${error}`)
).then(result => console.log(result.connected))
  .catch(error => console.error(error));

(async) getDRC20Balance(data, onSuccessopt, onErroropt) → {Promise.<{availableBalance: number, transferableBalance: number, ticker: string, address: string}>}

Retrieves the DRC20 token balance based on provided data.
Parameters:
NameTypeAttributesDescription
dataObjectData required to fetch the DRC20 balance, must contain 'ticker'.
Properties
NameTypeDescription
tickerstringThe ticker symbol for the DRC20 token.
onSuccessfunction<optional>
Optional callback function to execute upon successful retrieval. Receives an object containing the available balance, transferable balance, ticker symbol, and wallet address.
onErrorfunction<optional>
Optional callback function to execute upon error in retrieving balance.
Returns:
Promise object representing the outcome of the balance retrieval, resolving to an object with the wallet address, available balance, and transferable balance.
Type: 
Promise.<{availableBalance: number, transferableBalance: number, ticker: string, address: string}>
Example
getDRC20Balance(
  { ticker: 'DRC20' },
  (result) => console.log(`Available balance: ${result.availableBalance}, transferable balance: ${result.transferableBalance}`),
  (error) => console.error(`Balance retrieval failed: ${error}`)
).then(result => console.log(result.availableBalance))
  .catch(error => console.error(error));

(async) getDunesBalance(data, onSuccessopt, onErroropt) → {Promise.<{balance: number, ticker: string, address: string}>}

Retrieves the Dunes token balance based on provided data.
Parameters:
NameTypeAttributesDescription
dataObjectData required to fetch the Dunes balance, must contain 'ticker'.
Properties
NameTypeDescription
tickerstringThe ticker symbol for the Dunes token.
onSuccessfunction<optional>
Optional callback function to execute upon successful retrieval. Receives an object containing the balance, ticker symbol, and wallet address.
onErrorfunction<optional>
Optional callback function to execute upon error in retrieving balance.
Returns:
Promise object representing the outcome of the balance retrieval, resolving to an object with the wallet address, ticker and balance.
Type: 
Promise.<{balance: number, ticker: string, address: string}>
Example
getDunesBalance(
  { ticker: 'DUNES' },
  (result) => console.log(`Balance: ${result.balance}`),
  (error) => console.error(`Balance retrieval failed: ${error}`)
).then(result => console.log(result.availableBalance))
  .catch(error => console.error(error));

(async) getTransactionStatus(data, onSuccessopt, onErroropt) → {Promise.<{txId: string, confirmations: number, status: string, dogeAmount: number, blockTime: number, address: string}>}

Retrieves the status of a specific transaction based on provided data.
Parameters:
NameTypeAttributesDescription
dataObjectData required for the query, must contain 'txId'.
Properties
NameTypeDescription
txIdstringThe transaction ID to query.
onSuccessfunction<optional>
Optional callback function to execute upon successfully retrieving the status. Receives an object containing the number of txId, confirmations, status, amount, blockTime and address for the given tx.
onErrorfunction<optional>
Optional callback function to execute upon error in retrieving the tx status.
Returns:
Promise object representing the outcome of the tx retrieval, resolving to an object with the txId, confirmations, status, amount, blockTime and address for the given tx.
Type: 
Promise.<{txId: string, confirmations: number, status: string, dogeAmount: number, blockTime: number, address: string}>
Example
getTransactionStatus(
  { txId: '18d83f35060323a20e158805805e217b3ab7d849d5a1131f0ed8eba3a31c39a7' },
  (result) => console.log(`Trasaction status: ${result.status}`),
  (error) => console.error(`Transaction status retrieval failed: ${error}`)
).then(result => console.log(result.status))
  .catch(error => console.error(error));

(async) getTransferableDRC20(data, onSuccessopt, onErroropt) → {Promise.<{inscriptions: Array.<{txid: string, vout: number, ticker: string, contentType: string, content: string, location: string, amount: number}>, ticker: string, address: string}>}

Retrieves transferable DRC20 inscriptions based on provided data.
Parameters:
NameTypeAttributesDescription
dataObjectData required for the query, must contain 'ticker'.
Properties
NameTypeDescription
tickerstringThe ticker symbol for the DRC20 token.
onSuccessfunction<optional>
Optional callback function to execute upon successful retrieval. Receives an object containing the transferable inscriptions, ticker symbol, and wallet address.
onErrorfunction<optional>
Optional callback function to execute upon error in fetching the transferable balance.
Returns:
Promise object representing the outcome of the balance retrieval, resolving to an object with the wallet address, transferable inscriptions, and ticker symbol.}
Type: 
Promise.<{inscriptions: Array.<{txid: string, vout: number, ticker: string, contentType: string, content: string, location: string, amount: number}>, ticker: string, address: string}>
Example
getTransferableDRC20(
  { ticker: 'DRC20' },*
  (result) => console.log(`Transferable inscriptions: ${result.inscriptions}`),
  (error) => console.error(`Balance retrieval failed: ${error}`)
).then(result => console.log(result.inscriptions))
  .catch(error => console.error(error));

(async) requestAvailableDRC20Transaction(data, onSuccessopt, onErroropt) → {Promise.<{txId: string, ticker: string, amount: number}>}

Requests a transaction for available DRC20 tokens based on specified data.
Parameters:
NameTypeAttributesDescription
dataObjectData required for the transaction, must contain 'ticker' and 'amount'.
Properties
NameTypeDescription
tickerstringThe ticker symbol for the DRC20 token.
amountstringThe amount of DRC20 tokens to make available.
onSuccessfunction<optional>
Optional callback function to execute upon successful transaction request. Receives an object containing the transaction ID, ticker symbol, and amount.
onErrorfunction<optional>
Optional callback function to execute upon error in processing the transaction request.
Returns:
Promise object representing the outcome of the transaction request, resolving to an object with the transaction ID, ticker symbol, and amount.
Type: 
Promise.<{txId: string, ticker: string, amount: number}>
Example
requestInscriptionTransaction(
  { ticker: 'DRC20', amount: 100 },
  (result) => console.log(`Transaction ID: ${result.txId} `),
  (error) => console.error(`Transaction request failed: ${error}`)
).then(result => console.log(result.txId))
  .catch(error => console.error(error));

(async) requestDecryptedMessage(data, onSuccessopt, onErroropt) → {Promise.<{decryptedMessage: string}>}

Requests the decrypting of an arbitrary message encrypted by the connected address public key.
Parameters:
NameTypeAttributesDescription
dataObjectData required for the decryption, must contain 'message'.
Properties
NameTypeDescription
messagestringThe message to be decrypted.
onSuccessfunction<optional>
Optional callback function to execute upon successful message signing. Receives an object containing the decrypted message.
onErrorfunction<optional>
Callback function to execute upon error in decrypting the message.
Returns:
Promise object representing the outcome of the request, resolving to an object with the decrypted message.
Type: 
Promise.<{decryptedMessage: string}>
Example
requestDecryptedMessage(
  { message: 'STjKie7Bsm9/MtwkCimz2A==' },
  (result) => console.log(`Decrypted message: ${result.decryptedMessage}`),
  (error) => console.error(`Message decryption failed: ${error}`)
).then(result => console.log(result.decryptedMessage))
  .catch(error => console.error(error));

(async) requestDunesTransaction(data, onSuccessopt, onErroropt) → {Promise.<{txId: string, ticker: string, amount: number}>}

Requests a transaction for Dunes tokens based on specified data.
Parameters:
NameTypeAttributesDescription
dataObjectData required for the transaction, must contain 'ticker' and 'amount'.
Properties
NameTypeDescription
tickerstringThe ticker symbol for the Dunes token.
amountstringThe amount of Dunes tokens to make available.
recipientAddressstringThe Dogecoin address of the recipient.
onSuccessfunction<optional>
Optional callback function to execute upon successful transaction request. Receives an object containing the transaction ID, ticker symbol, and amount.
onErrorfunction<optional>
Optional callback function to execute upon error in processing the transaction request.
Returns:
Promise object representing the outcome of the transaction request, resolving to an object with the transaction ID, ticker symbol, and amount.
Type: 
Promise.<{txId: string, ticker: string, amount: number}>
Example
requestDunesTransaction(
  { ticker: 'DUNES', amount: 100, recipientAddress: 'DAHkCF5LajV6jYyi5o4eMvtpqXRcm9eZYq' },
  (result) => console.log(`Transaction ID: ${result.txId} `),
  (error) => console.error(`Transaction request failed: ${error}`)
).then(result => console.log(result.txId))
  .catch(error => console.error(error));

(async) requestInscriptionTransaction(data, onSuccessopt, onErroropt) → {Promise.<{txId: string}>}

Requests an inscription transaction for Doginal/DRC-20 based on the specified data.
Parameters:
NameTypeAttributesDescription
dataObjectData required for the transaction, must contain 'recipientAddress' and 'output'.
Properties
NameTypeDescription
recipientAddressstringThe recipient address.
locationstringThe location of the inscription in the format txid:vout:offset.
onSuccessfunction<optional>
Optional callback function to execute upon successful transaction request. Receives an object containing the transaction ID.
onErrorfunction<optional>
Optional function to execute upon error in processing the transaction request.
Returns:
Promise object representing the outcome of the transaction request, resolving to an object with the transaction ID.
Type: 
Promise.<{txId: string}>
Example
requestInscriptionTransaction(
  { recipientAddress: 'DAHkCF5LajV6jYyi5o4eMvtpqXRcm9eZYq', location: '18d83f35060323a20e158805805e217b3ab7d849d5a1131f0ed8eba3a31c39a7:0:0' },
  (result) => console.log(`Transaction ID: ${result.txId}`),
  (error) => console.error(`Transaction request failed: ${error}`)
).then(result => console.log(result.txId))
  .catch(error => console.error(error));

(async) requestPsbt(data, onSuccessopt, onErroropt) → {Promise.<{txId: string, signedRawTx: string}>}

Requests the signing of a partially signed Bitcoin transaction (PSBT) based on provided data.
Parameters:
NameTypeAttributesDescription
dataObjectData required for signing the PSBT, must contain 'rawTx' and an array of indexes to sign 'indexes'.
Properties
NameTypeDescription
rawTxstringThe raw transaction to be signed.
indexesArray.<number>The indexes of the inputs to be signed.
signOnlybooleanA flag to indicate whether to return the raw tx after signing instead of signing + sending (default: false)
partialbooleanA flag to indicate whether to create partial signatures. Only effective when signOnly is true (default: false)
sighashTypenumberThe signature hash type to use. Only effective when partial is true. Possible values: - SIGHASH_ALL (0x01): Signs all inputs and outputs (default) - SIGHASH_SINGLE (0x03): Signs all inputs, and the output with the same index - SIGHASH_ANYONECANPAY (0x80): Can be combined with above types using bitwise OR Combinations: - SIGHASH_ALL|SIGHASH_ANYONECANPAY (0x81): Signs one input and all outputs - SIGHASH_SINGLE|SIGHASH_ANYONECANPAY (0x83): Signs one input and one output at same index Note: - SIGHASH_NONE (0x02) is not supported for security reasons - it signs inputs but no outputs, allowing transaction outputs to be modified after signing
onSuccessfunction<optional>
Optional callback function to execute upon successful signing. Receives an object containing the transaction ID.
onErrorfunction<optional>
Callback function to execute upon error in signing the PSBT.
Returns:
Promise object representing the outcome of the transaction request, resolving to an object with the transaction ID or the signed raw transaction if signOnly = true.
Type: 
Promise.<{txId: string, signedRawTx: string}>
Example
requestPsbt(
  { rawTx: '02000000000101...', indexes: [0] },
  (result) => console.log(`Transaction ID: ${result.txId}`),
  (error) => console.error(`Transaction request failed: ${error}`)
).then(result => console.log(result.txId))
  .catch(error => console.error(error));

(async) requestSignedMessage(data, onSuccessopt, onErroropt) → {Promise.<{signedMessage: string}>}

Requests the signing of an arbitrary message based on provided data.
Parameters:
NameTypeAttributesDescription
dataObjectData required for the message signing, must contain 'message'.
Properties
NameTypeDescription
messagestringThe message to be signed.
onSuccessfunction<optional>
Optional callback function to execute upon successful message signing. Receives an object containing the signed message.
onErrorfunction<optional>
Callback function to execute upon error in signing the message.
Returns:
Promise object representing the outcome of the request, resolving to an object with the base64 signed message.
Type: 
Promise.<{signedMessage: string}>
Example
requestSignedMessage(
  { message: 'Hello, World!' },
  (result) => console.log(`Signed message: ${result.signedMessage}`),
  (error) => console.error(`Message signing failed: ${error}`)
).then(result => console.log(result.signedMessage))
  .catch(error => console.error(error));

(async) requestTransaction(data, onSuccessopt, onErroropt) → {Promise.<{txId: string}>}

Requests a Dogecoin transaction based on the specified data.
Parameters:
NameTypeAttributesDescription
dataObjectData needed for the transaction, must contain 'recipientAddress' and 'dogeAmount'.
Properties
NameTypeDescription
recipientAddressstringThe recipient address.
dogeAmountnumberThe amount of Dogecoin to send.
onSuccessfunction<optional>
Optional callback function to execute upon successful transaction request. Receives an object containing the transaction ID.
onErrorfunction<optional>
Optional callback function to execute upon error in processing the transaction request.
Returns:
Promise object representing the outcome of the transaction request, resolving to an object with the transaction ID.
Type: 
Promise.<{txId: string}>
Example
requestTransaction(
  { recipientAddress: 'DAHkCF5LajV6jYyi5o4eMvtpqXRcm9eZYq', dogeAmount: 100 },
  (result) => console.log(`Transaction ID: ${result.txId}`),
  (error) => console.error(`Transaction request failed: ${error}`)
).then(result => console.log(result.txId))
  .catch(error => console.error(error));