https://github.com/covenantsql/cql.js
General purpose library for CovenantSQL blockchain
https://github.com/covenantsql/cql.js
api blockchain covenantsql crypto javascript
Last synced: 6 months ago
JSON representation
General purpose library for CovenantSQL blockchain
- Host: GitHub
- URL: https://github.com/covenantsql/cql.js
- Owner: CovenantSQL
- License: apache-2.0
- Created: 2018-12-21T08:10:01.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T11:40:16.000Z (about 3 years ago)
- Last Synced: 2023-08-13T05:10:41.542Z (over 2 years ago)
- Topics: api, blockchain, covenantsql, crypto, javascript
- Language: TypeScript
- Homepage:
- Size: 1.08 MB
- Stars: 2
- Watchers: 3
- Forks: 4
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# cql.js
CovenantSQL's client side library
## Install
```
yarn add cql.js
```
or
```
npm i cql.js
```
## Usage
- Use `async` and `await` to handle requests
```javascript
import CQL from 'cql.js'
(async () => {
// For existing valid websocket endpoint
// please refer to https://developers.covenantsql.io
const endpoint = '$COVENANT_BP_WS_ENDPOINT'
const cql = new CQL(endpoint)
try {
await cql.connect()
} catch (e) {
console.error(e)
}
// connect success
let status = await cql.bp.getRunningStatus()
console.log('BP runing status: ', status)
})()
```
- Use promises to handle requests
```javascript
import CQL from 'cql.js'
// For existing valid websocket endpoint
// please refer to https://developers.covenantsql.io
const endpoint = '$COVENANT_BP_WS_ENDPOINT'
const cql = new CQL(endpoint)
cql
.connect()
.then(() => {
// connect success
cql.bp.getRunningStatus().then(status => {
console.log('BP runing status: ', status)
})
})
.catch(e => {
console.error(e)
})
```
## APIs
- `getProtocolVersion`
- `getRunningStatus`
- `getBlockList`
- `getBlockByHeight`
- `getBlockByHash`
- `getTransactionList`
- `getTransactionListOfBlock`
- `getTransactionByHash`