# @0xecho/core

> ## Install

Latest version **0.0.3** (published 2023-01-05) · 0 weekly downloads

## Install

```sh
npm install @0xecho/core
pnpm add @0xecho/core
yarn add @0xecho/core
bun add @0xecho/core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-01-05 |
| First published | 2022-12-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 580 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | airyland |

## Links

- npm: https://www.npmjs.com/package/@0xecho/core
- npm.io page: https://npm.io/package/@0xecho/core

## Dependencies (7)

- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [axios](https://npm.io/package/axios.md) ^1.2.0
- [emiter-js](https://npm.io/package/emiter-js.md) ^1.0.5
- [secp256k1](https://npm.io/package/secp256k1.md) ^4.0.3
- [sha256-uint8array](https://npm.io/package/sha256-uint8array.md) ^0.10.3
- [@ethersproject/bytes](https://npm.io/package/@ethersproject/bytes.md) ^5.7.0
- [@ethersproject/random](https://npm.io/package/@ethersproject/random.md) ^5.7.0

## Recent versions

- 0.0.3 (latest) — 2023-01-05
- 0.0.2 — 2023-01-05
- 0.0.1 — 2022-12-30

## README

# 0xecho/core

## Install

```
// cdn(recommended)
https://cdn.jsdelivr.net/npm/@0xecho/core/dist/index.min.js

// npm
npm install @0xecho/core

// yarn
yarn add @0xecho/core
```

## Usage


``` js
const echo = new EchoCore({
  node: 'https://sandbox.0xecho.com', // will use production node: https://node1.0xecho.com if not specified
  // loginAddress: '0x', you can force user to choose specified ethereum address for ECHO authorization
})

const isAuthorized = echo.isAuthorized() // check if user has login
const authorizedInfo = echo.getAuthorizedInfo()
console.log(isAuthorized, authorizedInfo)

// force user to authorize if needed
// await echo.authorize() 

// send a voting post
// will return 403 if user votes more than once for the same target_uri
try {
  const voteRs = await echo.post({
    type: 'vote',
    sub_type: 'single-choice', // only single-choice is supported now
    target_uri: 'test',
    content: '0',
    meta: {
      title: 'vote',
      body: 'body', // not required
      choices: [
        'hello',
        'world'
      ]
    }
  })
  console.log(voteRs)
} catch (e) {
  console.log(e)
}

// send a comment
try {
  const comment = await echo.post({
    type: 'comment',
    target_uri: 'test',
    content: 'hello'
  })
  console.log(comment)
} catch (e) {
  console.log(e)
}

// get posts
try {
  const rs = await echo.getPosts({
    type: 'vote',
    target_uri: 'test',
    created_by: 'EVM/0x3c98b726cd9e9f20becafd05a9affecd61617c0b' // EVM/ prefix is required for ethereum address
  })
  console.log('voting list', rs)
} catch (e) {
  console.log(e)
}
```

---
_Source: https://npm.io/package/@0xecho/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
