Socket
Socket
Sign inDemoInstall

concordapi

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concordapi - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

44

index.js
const req = require('requestify')
const basePublicUrl = 'https://www.cxd.network/api/public/v1/'
const basePrivateUrl = 'https://www.cxd.network/api/private/v1/'
var lastPrice = 0,

@@ -20,5 +21,5 @@ lastCoin = '',

if (err.body) {
console.log('ConcordAPI Error caught: (' + err.body + ')')
console.warn('ConcordAPI Error caught: (' + err.body + ')')
} else {
console.log('ConcordAPI Error caught: (' + err + ')')
console.warn('ConcordAPI Error caught: (' + err + ')')
}

@@ -44,5 +45,5 @@ if (lastCoin === coin) {

if (err.body) {
console.log('ConcordAPI Error caught: (' + err.body + ')')
console.warn('ConcordAPI Error caught: (' + err.body + ')')
} else {
console.log('ConcordAPI Error caught: (' + err + ')')
console.warn('ConcordAPI Error caught: (' + err + ')')
}

@@ -57,2 +58,33 @@ }

exports.send = async function (auth, amount, to) {
if (auth && auth != null && amount && amount != null && to && to != null && typeof auth === 'object' && auth.u && auth.p) {
try {
if (amount >= 0.0001) {
if (to.length >= 2) {
var response = await req.post(basePrivateUrl + 'send', {auth: auth, amount: amount, to: to})
return response.body
} else {
console.warn('Invalid Parameter, "To" is not a string with a length of atleast 2')
}
} else {
console.warn('Invalid Parameter, "Amount" is not a Number over atleast 0.0001')
}
} catch (err) {
if (err.body) {
if (err.body.includes('Insufficient') === false) {
console.warn('ConcordAPI Error caught: (' + err.body + ')')
} else {
return 'Insufficient Funds!'
}
} else {
if (err) { console.warn('ConcordAPI Error caught: (' + err + ')') }
}
}
} else if (typeof auth !== 'object') {
console.warn('Object variable missing, "' + typeof auth + ' - ' + auth + '" was recieved')
} else {
console.warn('Invalid Parameters, please ensure you have provided the following variables:\nObject: auth {String: p, String:u}\nNumber: amount\nString: to\nSee "GitHub - Concord-API-NodeJS - README.md" for more info')
}
}
exports.getUser = async function (discordID) {

@@ -69,5 +101,5 @@ if (discordID && discordID != null && typeof discordID === 'string' && discordID.length === 18) {

if (err.body) {
console.log('ConcordAPI Error caught: (' + err.body + ')')
console.warn('ConcordAPI Error caught: (' + err.body + ')')
} else {
console.log('ConcordAPI Error caught: (' + err + ')')
console.warn('ConcordAPI Error caught: (' + err + ')')
}

@@ -74,0 +106,0 @@ }

2

package.json
{
"name": "concordapi",
"version": "1.1.1",
"version": "1.2.0",
"description": "The Official Concord REST API Package for Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,3 +6,3 @@ # ConcordAPI

**Notice:** This module is in early development, and may have minor bugs and inconveniences, this module is under active development by the Concord Team
**Notice:** This module is in early development, and may have minor bugs and inconveniences, this module is under active development by the Concord Team and Community

@@ -66,4 +66,28 @@

## Sending a Transaction through ConcordPay
ConcordPay is a simple online interface for the Lightnet transaction system, transactions can be sent directly to any registered Lightnet User from any integrated Platform.
To send a transaction, you first need to provide your Concord Home account credentials in an Object, as shown below:
```js
var auth = {u: 'username-here', p: 'password-here'} /* Replace values with your real credentials! */
```
Once you've entered your Auth-data, send your transaction!
```js
var amount = 25 /* The amount of Concord (CXD) you are sending */
var to = 'username-of-transaction-receiver' /* This is the user Receiving the transaction */
concord.send(auth, amount, to).then(response => { /* Sends your Auth and Transaction data to Lightnet for processing */
console.log(response) /* Logs the API's response to the console. E.G: "(User)'s Payment Has Sent!'" */
})
```
And to Receive transactions, simply give your Concord Home username to the application/user that wants to pay you
## Full Examples
Examples in this section can be freely copy/pasted into your code and modified to your choosing, and when unmodified, "just work"
Examples in this section can be freely copy/pasted into your code and modified to your choosing, and when unmodified and authenticated, "just work"
### Example 1. Continuously pulling a Concord Exchange coin price
```js

@@ -82,1 +106,12 @@ /* This script would run indefinitely until the console/terminal is closed manually */

```
### Example 2. Authenticating and sending a Transaction
```js
var auth = {u: 'username-here', p: 'password-here'}
var amount = 25 /* The amount of Concord (CXD) you are sending */
var to = 'username-of-receiver' /* This is the user Receiving the transaction */
concord.send(auth, amount, to).then(response => { /* The API Package function, to send the payment to the Lightnet Server */
console.log(response) /* Logs the API's response to the console. E.G: "(User)'s Payment Has Sent!'" */
})
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc