quantum-coin-js-sdk
v1.0.14
Published
Quantum Coin - Q SDK in JavaScript
Downloads
94
Maintainers
Readme
quantum-coin-js-sdk
Quantum Coin JS SDK provides functionality to interact with the Quantum Coin Blockchain using the Relay APIs. Example Project
Example
Requires Node.js version v20.18.1 or higher
Installation:
npm install quantum-coin-js-sdk --save
//Adding reference:
var qcsdk = require('quantum-coin-js-sdk');
//Initialize the SDK first before invoking any other function
var clientConfigVal = new qcsdk.Config("https://t4-relayread.quantumcoin.org", "https://t4-relaywrite.quantumcoin.org", 310324, "", ""); //Testnet T4 Block Explorer: https://t4.scan.quantumcoin.org
qcsdk.initialize(clientConfigVal).then((initResult) => {
}
Example Project: https://github.com/quantumcoinproject/quantum-coin-js-sdk/tree/main/example
- quantum-coin-js-sdk
- ~Config
- new Config(readUrl, writeUrl, chainId, readApiKey, writeApiKey)
- .readUrl : string
- .writeUrl : string
- .chainId : number
- .readApiKey : string
- .writeApiKey : string
- ~Wallet
- ~BlockDetails
- .blockNumber : number
- ~LatestBlockDetailsResult
- .resultCode : number
- .blockDetails : BlockDetails
- .response : Object
- .requestId : string
- .err : error
- ~AccountDetails
- .address : string
- .balance : string
- .nonce : number
- .blockNumber : number
- ~AccountDetailsResult
- .resultCode : number
- .accountDetails : AccountDetails
- .response : Object
- .requestId : string
- .err : error
- ~SignResult
- .resultCode : number
- .txnHash : string
- .txnData : string
- ~SendResult
- .resultCode : number
- .txnHash : string
- .response : Object
- .requestId : string
- .err : error
- ~TransactionReceipt
- .cumulativeGasUsed : string
- .effectiveGasPrice : string
- .gasUsed : string
- .status : string
- .hash : string
- .type : string
- ~TransactionDetails
- ~TransactionDetailsResult
- .resultCode : number
- .transactionDetails : TransactionDetails
- .response : Object
- .requestId : string
- .err : error
- ~AccountTransactionCompact
- ~ListAccountTransactionsResponse
- .pageCount : number
- .items : AccountTransactionCompact | Array
- ~AccountTransactionsResult
- .resultCode : number
- .listAccountTransactionsResponse : ListAccountTransactionsResponse
- .response : Object
- .requestId : string
- .err : error
- ~initialize(clientConfig) ⇒ Promise.<boolean>
- ~isAddressValid(address) ⇒ boolean
- ~newWallet() ⇒ Wallet
- ~verifyWallet(wallet) ⇒ boolean
- ~serializeWallet(wallet) ⇒ string
- ~deserializeWallet(walletJson) ⇒ Wallet
- ~postTransaction(txnData) ⇒ Promise.<SendResult>
- ~getLatestBlockDetails() ⇒ Promise.<BlockDetailsResult>
- ~getAccountDetails(address) ⇒ Promise.<AccountDetailsResult>
- ~getTransactionDetails(txnHash) ⇒ Promise.<TransactionDetailsResult>
- ~listAccountTransactions(address, pageNumber) ⇒ Promise.<ListAccountTransactionsResponse>
- ~signSendCoinTransaction(wallet, toAddress, coins, nonce) ⇒ SignResult
- ~sendCoins(wallet, toAddress, coins, nonce) ⇒ Promise.<SendResult>
- ~Config
quantum-coin-js-sdk~Config
This is the configuration class required to initialize and interact with Quantum Coin blockchain
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~Config
- new Config(readUrl, writeUrl, chainId, readApiKey, writeApiKey)
- .readUrl : string
- .writeUrl : string
- .chainId : number
- .readApiKey : string
- .writeApiKey : string
new Config(readUrl, writeUrl, chainId, readApiKey, writeApiKey)
Creates a config class
| Param | Type | Description | | --- | --- | --- | | readUrl | string | The Read API URL pointing to a read relay. See https://github.com/DogeProtocol/go-dp/tree/dogep/relay. The following URLs are community maintained. Please use your own relay service. Mainnet: https://relayread.quantumcoin.org Testnet T4: https://t4-relayread.quantumcoin.org | | writeUrl | string | The Write API URL pointing to a write relay. See https://github.com/DogeProtocol/go-dp/tree/dogep/relay. The following URLs are community maintained. Please use your own relay service. Mainnet: https://relaywrite.quantumcoin.org Testnet T4: https://t4-relaywrite.quantumcoin.org | | chainId | number | The chain id of the blockchain. Mainnet chainId is 123123. Testnet T4 chainId is 310324. | | readApiKey | string | Optional parameter if authorization is enabled for the relay service. API Key for authorization. Defaults to null which indicates no authorization. | | writeApiKey | string | Optional parameter if authorization is enabled for the relay service. API Key for authorization. Defaults to null which indicates no authorization. |
config.readUrl : string
The Read API URL pointing to a read relay. See https://github.com/DogeProtocol/go-dp/tree/dogep/relay
Kind: instance property of Config
Access: public
config.writeUrl : string
The Read API URL pointing to a read relay. See https://github.com/DogeProtocol/go-dp/tree/dogep/relay
Kind: instance property of Config
Access: public
config.chainId : number
The chain id of the blockchain. Mainnet chainId is 123123. Testnet T4 chainId is 310324.
Kind: instance property of Config
Access: public
config.readApiKey : string
API Key for authorization if authorization is enabled for the relay service. Defaults to null which indicates no authorization.
Kind: instance property of Config
Access: public
config.writeApiKey : string
API Key for authorization if authorization is enabled for the relay service. Defaults to null which indicates no authorization.
Kind: instance property of Config
Access: public
quantum-coin-js-sdk~Wallet
This class represents a Wallet. Use the verifyWallet function to verify if a wallet is valid. Verifying the wallet is highly recommended, especially if it comes from an untrusted source. For more details on the underlying cryptography of the Wallet, see https://github.com/DogeProtocol/hybrid-pqc
Kind: inner class of quantum-coin-js-sdk
Access: public
new Wallet(address, privateKey, publicKey)
Creates a Wallet class. The constructor does not verify the wallet. To verify a wallet, call the verifyWallet function explicitly.
| Param | Type | Description | | --- | --- | --- | | address | string | Address of the wallet | | privateKey | Array.<byte> | Private Key byte array of the wallet | | publicKey | Array.<byte> | The chain id of the blockchain. Mainnet chainId is 123123. Testnet T4 chainId is 310324. |
wallet.address : string
Address of the wallet. Is 66 bytes in length including 0x (if the wallet is valid).
Kind: instance property of Wallet
Access: public
wallet.privateKey
Private Key byte array of the wallet. Is 4064 bytes in length (if the wallet is valid).
Kind: instance property of Wallet
Access: public
wallet.publicKey
Public Key byte array of the wallet. Is 1408 bytes in length (if the wallet is valid).
Kind: instance property of Wallet
Access: public
quantum-coin-js-sdk~BlockDetails
This class represents a Block.
Kind: inner class of quantum-coin-js-sdk
Access: public
blockDetails.blockNumber : number
Block Number of the block
Kind: instance property of BlockDetails
Access: public
quantum-coin-js-sdk~LatestBlockDetailsResult
This class represents a result from invoking the getLatestBlock function.
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~LatestBlockDetailsResult
- .resultCode : number
- .blockDetails : BlockDetails
- .response : Object
- .requestId : string
- .err : error
latestBlockDetailsResult.resultCode : number
Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
Kind: instance property of LatestBlockDetailsResult
Access: public
latestBlockDetailsResult.blockDetails : BlockDetails
An object of type BlockDetails representing the block. This value is null if the value of resultCode is not 0.
Kind: instance property of LatestBlockDetailsResult
Access: public
latestBlockDetailsResult.response : Object
An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
Kind: instance property of LatestBlockDetailsResult
Access: public
latestBlockDetailsResult.requestId : string
An unique id to represent the request. This can be null if request failed before it could be sent.
Kind: instance property of LatestBlockDetailsResult
Access: public
latestBlockDetailsResult.err : error
An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
Kind: instance property of LatestBlockDetailsResult
Access: public
quantum-coin-js-sdk~AccountDetails
This class represents an Account.
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~AccountDetails
- .address : string
- .balance : string
- .nonce : number
- .blockNumber : number
accountDetails.address : string
Address of the wallet. Is 66 bytes in length including 0x.
Kind: instance property of AccountDetails
Access: public
accountDetails.balance : string
Balance of the account in wei. To convert this to ethers, see https://docs.ethers.org/v4/api-utils.html#ether-strings-and-wei
Kind: instance property of AccountDetails
Access: public
accountDetails.nonce : number
A monotonically increasing number representing the nonce of the account. After each transaction from the account that gets registered in the blockchain, the nonce increases by 1.
Kind: instance property of AccountDetails
Access: public
accountDetails.blockNumber : number
The block number as of which the Account details was retrieved.
Kind: instance property of AccountDetails
Access: public
quantum-coin-js-sdk~AccountDetailsResult
This class represents a result from invoking the getAccountDetails function.
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~AccountDetailsResult
- .resultCode : number
- .accountDetails : AccountDetails
- .response : Object
- .requestId : string
- .err : error
accountDetailsResult.resultCode : number
Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
Kind: instance property of AccountDetailsResult
Access: public
accountDetailsResult.accountDetails : AccountDetails
An object of type AccountDetails representing the block. This value is null if the value of resultCode is not 0.
Kind: instance property of AccountDetailsResult
Access: public
accountDetailsResult.response : Object
An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
Kind: instance property of AccountDetailsResult
Access: public
accountDetailsResult.requestId : string
An unique id to represent the request. This can be null if request failed before it could be sent.
Kind: instance property of AccountDetailsResult
Access: public
accountDetailsResult.err : error
An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
Kind: instance property of AccountDetailsResult
Access: public
quantum-coin-js-sdk~SignResult
This class represents a result from invoking the signSendCoinTransaction function.
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~SignResult
- .resultCode : number
- .txnHash : string
- .txnData : string
signResult.resultCode : number
Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
Kind: instance property of SignResult
Access: public
signResult.txnHash : string
Hash of the Transaction, to uniquely identify it. Is 66 bytes in length including 0x. This value is null if the value of resultCode is not 0.
Kind: instance property of SignResult
Access: public
signResult.txnData : string
A payload representing the signed transaction. To actually send a transaction, this payload can then be taken to to a different device that is connected to the blockchain relay and then sent using the postTransaction function. This value is null if the value of resultCode is not 0.
Kind: instance property of SignResult
Access: public
quantum-coin-js-sdk~SendResult
This class represents a result from invoking the sendCoins function.
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~SendResult
- .resultCode : number
- .txnHash : string
- .response : Object
- .requestId : string
- .err : error
sendResult.resultCode : number
Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
Kind: instance property of SendResult
Access: public
sendResult.txnHash : string
Hash of the Transaction, to uniquely identify it. Is 66 bytes in length including 0x. This value is null if the value of resultCode is not 0.
Kind: instance property of SendResult
Access: public
sendResult.response : Object
An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
Kind: instance property of SendResult
Access: public
sendResult.requestId : string
An unique id to represent the request. This can be null if request failed before it could be sent.
Kind: instance property of SendResult
Access: public
sendResult.err : error
An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
Kind: instance property of SendResult
Access: public
quantum-coin-js-sdk~TransactionReceipt
This class represents a Receipt of a transaction that is registered in the blockchain. The transactionReceipt field can be null unless the transaction is registered with the blockchain. While the transaction is pending, this field will be null. You should consider the transaction as succeeded only if the status field's value is 0x1 (success).
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~TransactionReceipt
- .cumulativeGasUsed : string
- .effectiveGasPrice : string
- .gasUsed : string
- .status : string
- .hash : string
- .type : string
transactionReceipt.cumulativeGasUsed : string
A hexadecimal string representing the total amount of gas used when this transaction was executed in the block.
Kind: instance property of TransactionReceipt
Access: public
transactionReceipt.effectiveGasPrice : string
A hexadecimal string representing the sum of the base fee and tip paid per unit of gas.
Kind: instance property of TransactionReceipt
Access: public
transactionReceipt.gasUsed : string
A hexadecimal string representing the amount of gas used by this specific transaction alone.
Kind: instance property of TransactionReceipt
Access: public
transactionReceipt.status : string
A hexadecimal string representing either 0x1 (success) or 0x0 (failure). Failed transactions can also incur gas fee. You should consider the transaction as succeeded only if the status value is 0x1 (success).
Kind: instance property of TransactionReceipt
Access: public
transactionReceipt.hash : string
Hash of the Transaction, to uniquely identify it. Is 66 bytes in length including 0x.
Kind: instance property of TransactionReceipt
Access: public
transactionReceipt.type : string
A hexadecimal string representing the transaction type. 0x0 is DefaultFeeTxType.
Kind: instance property of TransactionReceipt
Access: public
quantum-coin-js-sdk~TransactionDetails
This class represents details of a transaction. You should consider the transaction as succeeded only if the status field of the receipt object is 0x1 (success).
Kind: inner class of quantum-coin-js-sdk
Access: public
transactionDetails.blockHash : string
A hexadecimal string representing the hash of the block that registered the transaction. This field can be null if the transaction was not registered in the blockchain.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.blockNumber : number
The number of the block that registered the transaction. This field can be null if the transaction was not registered in the blockchain.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.from : string
A 66 character hexadecimal string representing the address the transaction is sent from.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.gas : string
A hexadecimal string representing the gas provided for the transaction execution.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.gasPrice : string
A hexadecimal string representing the gasPrice used for each paid gas, in Wei.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.hash : string
A 66 character hexadecimal string representing the hash of the transaction.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.input : string
A hexadecimal string representing the compiled code of a contract OR the hash of the invoked method signature and encoded parameters.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.nonce : number
A monotonically increasing number representing the nonce of the account. After each transaction from the account that gets registered in the blockchain, the nonce increases by 1.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.to : string
A 66 character hexadecimal string representing address the transaction is directed to.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.value : string
A hexadecimal string representing the value sent with this transaction. The value can be 0 for smart contract transactions, since it only represents the number of coins sent.
Kind: instance property of TransactionDetails
Access: public
transactionDetails.receipt : TransactionReceipt
The receipt of the transaction. This field will be null while the transaction is pending (not yet registered in the blockchain).
Kind: instance property of TransactionDetails
Access: public
quantum-coin-js-sdk~TransactionDetailsResult
This class represents a result from invoking the getTransactionDetails function. If transactions get discarded by the blockchain, for reasons such as due to lower than minimum gas fees or invalid nonce, the resultCode will always contain a non-zero value (failure).
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~TransactionDetailsResult
- .resultCode : number
- .transactionDetails : TransactionDetails
- .response : Object
- .requestId : string
- .err : error
transactionDetailsResult.resultCode : number
Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
Kind: instance property of TransactionDetailsResult
Access: public
transactionDetailsResult.transactionDetails : TransactionDetails
An object of type TransactionDetails representing the transaction. This value is null if the value of resultCode is not 0.
Kind: instance property of TransactionDetailsResult
Access: public
transactionDetailsResult.response : Object
An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
Kind: instance property of TransactionDetailsResult
Access: public
transactionDetailsResult.requestId : string
An unique id to represent the request. This can be null if request failed before it could be sent.
Kind: instance property of TransactionDetailsResult
Access: public
transactionDetailsResult.err : error
An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
Kind: instance property of TransactionDetailsResult
Access: public
quantum-coin-js-sdk~AccountTransactionCompact
This class represents a transaction of an account. You should consider the transaction as succeeded only if the status field is 0x1 (success).
Kind: inner class of quantum-coin-js-sdk
Access: public
accountTransactionCompact.blockNumber : number
The number of the block that registered the transaction. This field can be null if the transaction was not registered in the blockchain.
Kind: instance property of AccountTransactionCompact
Access: public
accountTransactionCompact.from : string
A 66 character hexadecimal string representing the address the transaction is sent from.
Kind: instance property of AccountTransactionCompact
Access: public
accountTransactionCompact.hash : string
A 66 character hexadecimal string representing the hash of the transaction.
Kind: instance property of AccountTransactionCompact
Access: public
accountTransactionCompact.to : string
A 66 character hexadecimal string representing address the transaction is directed to.
Kind: instance property of AccountTransactionCompact
Access: public
accountTransactionCompact.value : string
A hexadecimal string representing the value sent with this transaction. The value can be 0 for smart contract transactions, since it only represents the number of coins sent.
Kind: instance property of AccountTransactionCompact
Access: public
accountTransactionCompact.status : string
A hexadecimal string representing either 0x1 (success) or 0x0 (failure). Failed transactions can also incur gas fee. You should consider the transaction as succeeded only if the status value is 0x1 (success).
Kind: instance property of AccountTransactionCompact
Access: public
quantum-coin-js-sdk~ListAccountTransactionsResponse
This class represents a list of account transactions returned by the listAccountTransactionDetails function.
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~ListAccountTransactionsResponse
- .pageCount : number
- .items : AccountTransactionCompact | Array
listAccountTransactionsResponse.pageCount : number
The number of pages available for listing.
Kind: instance property of ListAccountTransactionsResponse
Access: public
listAccountTransactionsResponse.items : AccountTransactionCompact | Array
An array of type AccountTransactionCompact, containing the list of transactions. Can be null if no items are available.
Kind: instance property of ListAccountTransactionsResponse
Access: public
quantum-coin-js-sdk~AccountTransactionsResult
This class represents a result from invoking the listAccountTransactionDetails function.
Kind: inner class of quantum-coin-js-sdk
Access: public
- ~AccountTransactionsResult
- .resultCode : number
- .listAccountTransactionsResponse : ListAccountTransactionsResponse
- .response : Object
- .requestId : string
- .err : error
accountTransactionsResult.resultCode : number
Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
Kind: instance property of AccountTransactionsResult
Access: public
accountTransactionsResult.listAccountTransactionsResponse : ListAccountTransactionsResponse
An object of type ListAccountTransactionsResponse representing the list of transactions along with metadata. This value is null if the value of resultCode is not 0.
Kind: instance property of AccountTransactionsResult
Access: public
accountTransactionsResult.response : Object
An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
Kind: instance property of AccountTransactionsResult
Access: public
accountTransactionsResult.requestId : string
An unique id to represent the request. This can be null if request failed before it could be sent.
Kind: instance property of AccountTransactionsResult
Access: public
accountTransactionsResult.err : error
An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
Kind: instance property of AccountTransactionsResult
Access: public
quantum-coin-js-sdk~initialize(clientConfig) ⇒ Promise.<boolean>
The initialize function has to be called before attempting to invoke any other function. This function should be called only once.
Kind: inner method of quantum-coin-js-sdk
Returns: Promise.<boolean> - Returns a promise of type boolean; true if the initialization succeeded, else false.
| Param | Type | Description | | --- | --- | --- | | clientConfig | Config | A configuration represented by the Config class |
quantum-coin-js-sdk~isAddressValid(address) ⇒ boolean
The isAddressValid function validates whether an address is valid or not. An address is of length 66 characters including 0x.
Kind: inner method of quantum-coin-js-sdk
Returns: boolean - Returns true if the address validation succeeded, else returns false.
| Param | Type | Description | | --- | --- | --- | | address | string | A string representing the address to validate. |
quantum-coin-js-sdk~newWallet() ⇒ Wallet
The newWallet function creates a new Wallet.
Kind: inner method of quantum-coin-js-sdk
Returns: Wallet - Returns a Wallet object.
quantum-coin-js-sdk~verifyWallet(wallet) ⇒ boolean
The verifyWallet function verifies whether a Wallet is valid or not. To mitigate spoofing and other attachs, it is highly recommended to verify a wallet, especially if it is from an untrusted source.
Kind: inner method of quantum-coin-js-sdk
Returns: boolean - Returns true if the Wallet verification succeeded, else returns false.
| Param | Type | Description | | --- | --- | --- | | wallet | Wallet | A Wallet object representing the wallet to verify. |
quantum-coin-js-sdk~serializeWallet(wallet) ⇒ string
The serializeWallet function serializes a Wallet object to a JSON string. You should encrypt the string before saving it to disk or a database.
Kind: inner method of quantum-coin-js-sdk
Returns: string - Returns the Wallet in JSON string format. If the wallet is invalid, null is returned.
| Param | Type | Description | | --- | --- | --- | | wallet | Wallet | A Wallet object representing the wallet to serialize. |
quantum-coin-js-sdk~deserializeWallet(walletJson) ⇒ Wallet
The deserializeWallet function creates a Wallet object from a JSON string.
Kind: inner method of quantum-coin-js-sdk
Returns: Wallet - Returns the Wallet corresponding to the walletJson. If the wallet is invalid, null is returned.
| Param | Type | Description | | --- | --- | --- | | walletJson | string | A Wallet object representing the wallet to deserialize. |
quantum-coin-js-sdk~postTransaction(txnData) ⇒ Promise.<SendResult>
The postTransaction function posts a signed transaction to the blockchain. This method can be used in conjunction with the signSendCoinTransaction method to submit a transaction that was signed using a cold wallet (offline or disconnected or air-gapped wallet).
Kind: inner method of quantum-coin-js-sdk
Returns: Promise.<SendResult> - Returns a promise of type SendResult. txnHash will be null in SendResult.
| Param | Type | Description | | --- | --- | --- | | txnData | string | A signed transaction string returned by the signSendCoinTransaction function. |
quantum-coin-js-sdk~getLatestBlockDetails() ⇒ Promise.<BlockDetailsResult>
The getLatestBlockDetails function returns details of the latest block of the blockchain.
Kind: inner method of quantum-coin-js-sdk
Returns: Promise.<BlockDetailsResult> - Returns a promise of an object of type BlockDetailsResult.
quantum-coin-js-sdk~getAccountDetails(address) ⇒ Promise.<AccountDetailsResult>
The getAccountDetails function returns details of an account corresponding to the address.
Kind: inner method of quantum-coin-js-sdk
Returns: Promise.<AccountDetailsResult> - Returns a promise of type AccountDetailsResult.
| Param | Type | Description | | --- | --- | --- | | address | string | The address of the account of which the details have to be retrieved. |
quantum-coin-js-sdk~getTransactionDetails(txnHash) ⇒ Promise.<TransactionDetailsResult>
The getTransactionDetails function returns details of a transaction posted to the blockchain. Transactions may take a while to get registered in the blockchain. After a transaction is submitted, it may take a while before it is available for reading. Some transactions that have lower balance than the minimum required for gas fees may be discarded. In these cases, the transactions may not be returned when invoking the getTransactionDetails function. You should consider the transaction as succeeded only if the status field of the transactionReceipt object is 0x1 (success). The transactionReceipt field can be null unless the transaction is registered with the blockchain.
Kind: inner method of quantum-coin-js-sdk
Returns: Promise.<TransactionDetailsResult> - Returns a promise of type type TransactionDetailsResult.
| Param | Type | Description | | --- | --- | --- | | txnHash | string | The hash of the transaction to retrieve. |
quantum-coin-js-sdk~listAccountTransactions(address, pageNumber) ⇒ Promise.<ListAccountTransactionsResponse>
The listAccountTransactions function returns a list of transactions for a specific account. Transactions may take a while to get registered in the blockchain. After a transaction is submitted, it may take a while before it is available for listing. Some transactions that have lower balance than the minimum required for gas fees may be discarded. In these cases, the transactions may not be returned when invoking the listAccountTransactions function. You should consider the transaction as succeeded only if the status field AccountDetailsCompact object is 0x1 (success). Both transactions from and transactions to the address will be returned in the list. Use the getTransactionDetails function, passing the hash of the transaction to get detailed information about the transaction.
Kind: inner method of quantum-coin-js-sdk
Returns: Promise.<ListAccountTransactionsResponse> - Returns a promise of type type ListAccountTransactionsResponse.
| Param | Type | Description | | --- | --- | --- | | address | string | The address for which the transactions have to be listed. | | pageNumber | number | The page number for which the transactions has to be listed for the account. Pass 0 to list the latest page. |
quantum-coin-js-sdk~signSendCoinTransaction(wallet, toAddress, coins, nonce) ⇒ SignResult
The signSendCoinTransaction function returns a signed transaction. Since the gas fee for sending coins is fixed at 1000 coins, there is no option to set the gas fee explicitly. This function is useful for offline (cold storage) wallets, where you can sign a transaction offline and then use the postTransaction function to post it on a connected device. Another usecase for this function is when you want to first store a signed transaction to a database, then queue it and finally submit the transaction by calling the postTransaction function.
Kind: inner method of quantum-coin-js-sdk
Returns: SignResult - Returns a promise of type SignResult.
| Param | Type | Description | | --- | --- | --- | | wallet | Wallet | A Wallet object from which the transaction has to be sent. The address corresponding to the Wallet should have enough coins to cover gas fees as well. A minimum of 1000 coins (1000000000000000000000 wei) are required for gas fees. | | toAddress | string | The address to which the coins should be sent. | | coins | string | The string representing the number of coins (in ether) to send. To convert between ethers and wei, see https://docs.ethers.org/v4/api-utils.html#ether-strings-and-wei | | nonce | number | The nonce of the account retrieved by invoking the getAccountDetails function. You have to carefully manage state of the nonce to avoid sending the coins multiple times, such as when retrying sendCoins after a network error. |
quantum-coin-js-sdk~sendCoins(wallet, toAddress, coins, nonce) ⇒ Promise.<SendResult>
The sendCoins function posts a send-coin transaction to the blockchain. Since the gas fee for sending coins is fixed at 1000 coins, there is no option to set the gas fee explicitly. It may take many seconds after submitting a transaction before the transaction is returned by the getTransactionDetails function. Transactions are usually committed in less than 30 seconds.
Kind: inner method of quantum-coin-js-sdk
Returns: Promise.<SendResult> - Returns a promise of type SendResult.
| Param | Type | Description | | --- | --- | --- | | wallet | Wallet | A Wallet object from which the transaction has to be sent. The address corresponding to the Wallet should have enough coins to cover gas fees as well. A minimum of 1000 coins (1000000000000000000000 wei) are required for gas fees. | | toAddress | string | The address to which the coins should be sent. | | coins | string | The string representing the number of coins (in ether) to send. To convert between ethers and wei, see https://docs.ethers.org/v4/api-utils.html#ether-strings-and-wei | | nonce | number | The nonce of the account retrieved by invoking the getAccountDetails function. You have to carefully manage state of the nonce to avoid sending the coins multiple times, such as when retrying sendCoins after a network error. |