This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

qc-sdk

1.0.4 • Public • Published

qc-sdk

Quantum Coin SDK provides functionality to interact with the Quantum Coin Blockchain using the Relay APIs. Example Project

Example

Installation:
npm install qc-sdk --save

Adding reference:
var qcsdk = require('qc-sdk');

Example Project: https://github.com/DogeProtocol/qc-sdk/example

qc-sdk~Config

This is the configuration class required to initialize and interact with Quantum Coin blockchain

Kind: inner class of qc-sdk
Access: public

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

qc-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 qc-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

qc-sdk~BlockDetails

This class represents a Block.

Kind: inner class of qc-sdk
Access: public

blockDetails.blockNumber : number

Block Number of the block

Kind: instance property of BlockDetails
Access: public

qc-sdk~LatestBlockDetailsResult

This class represents a result from invoking the getLatestBlock function.

Kind: inner class of qc-sdk
Access: public

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

qc-sdk~AccountDetails

This class represents an Account.

Kind: inner class of qc-sdk
Access: public

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

qc-sdk~AccountDetailsResult

This class represents a result from invoking the getAccountDetails function.

Kind: inner class of qc-sdk
Access: public

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

qc-sdk~SignResult

This class represents a result from invoking the signSendCoinTransaction function.

Kind: inner class of qc-sdk
Access: public

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

qc-sdk~SendResult

This class represents a result from invoking the sendCoins function.

Kind: inner class of qc-sdk
Access: public

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

qc-sdk~TransactionReceipt

This class represents a Receipt of a transaction that was 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 qc-sdk
Access: public

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

qc-sdk~TransactionDetails

This class represents a result from invoking the getTransactionDetails function. You should consider the transaction as succeeded only if the status field of the receipt object is 0x1 (success).

Kind: inner class of qc-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 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

qc-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 qc-sdk
Access: public

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 block. 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

qc-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 qc-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

qc-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 qc-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.

qc-sdk~newWallet() ⇒ Wallet

The newWallet function creates a new Wallet.

Kind: inner method of qc-sdk
Returns: Wallet - Returns a Wallet object.

qc-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 qc-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.

qc-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 qc-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.

qc-sdk~deserializeWallet(walletJson) ⇒ Wallet

The deserializeWallet function creates a Wallet object from a JSON string.

Kind: inner method of qc-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.

qc-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 qc-sdk
Returns: Promise.<SendResult> - Returns a promise of type SendResult.

Param Type Description
txnData string A signed transaction string returned by the signSendCoinTransaction function.

qc-sdk~getLatestBlockDetails() ⇒ Promise.<BlockDetailsResult>

The getLatestBlockDetails function returns details of the latest block of the blockchain.

Kind: inner method of qc-sdk
Returns: Promise.<BlockDetailsResult> - Returns a promise of an object of type BlockDetailsResult.

qc-sdk~getAccountDetails(address) ⇒ Promise.<AccountDetailsResult>

The getAccountDetails function returns details of an account corresponding to the address.

Kind: inner method of qc-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.

qc-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. 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 qc-sdk
Returns: Promise.<TransactionDetailsResult> - Returns a promise of type type TransactionDetailsResult.

Param Type Description
txnHash string The hash of the transaction to retrieve.

qc-sdk~signSendCoinTransaction(wallet, toAddress, coinsInWei, nonce) ⇒ SignResult

The signSendCoinTransaction function returns a signed transaction. 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.

Kind: inner method of qc-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.
coinsInWei string The string representing the number of coins (in wei) 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.

qc-sdk~sendCoins(wallet, toAddress, coinsInWei, nonce) ⇒ Promise.<SendResult>

The sendCoins function posts a send-coin transaction to the blockchain.

Kind: inner method of qc-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.
coinsInWei string The string representing the number of coins (in wei) 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.

Package Sidebar

Install

npm i qc-sdk

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

6.73 MB

Total Files

10

Last publish

Collaborators

  • dogeprotocol