# @dcl/quests-client

> Quests Client

Latest version **1.0.3** (published 2023-10-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @dcl/quests-client
pnpm add @dcl/quests-client
yarn add @dcl/quests-client
bun add @dcl/quests-client
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-10-25 |
| First published | 2023-06-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 937.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | decentralandbot |
| Keywords | decentraland, quests |

## Links

- npm: https://www.npmjs.com/package/@dcl/quests-client
- Repository: https://github.com/decentraland/quests-client
- Homepage: https://github.com/decentraland/quests-client#readme
- Issues: https://github.com/decentraland/quests-client/issues
- npm.io page: https://npm.io/package/@dcl/quests-client

## Dependencies (4)

- [mitt](https://npm.io/package/mitt.md) ^3.0.1
- [@dcl/rpc](https://npm.io/package/@dcl/rpc.md) ^1.1.2
- [@dcl/sdk](https://npm.io/package/@dcl/sdk.md) latest
- [@dcl/protocol](https://npm.io/package/@dcl/protocol.md) ^1.0.0-6160718705.commit-03626d7

## Recent versions

- 1.0.3 (latest) — 2023-10-25
- 1.0.3-20231025131529.commit-ab10531 (next) — 2023-10-25
- 1.0.2 — 2023-10-24
- 1.0.2-20231024193022.commit-5a9b889 — 2023-10-24
- 1.0.1 — 2023-10-24
- 1.0.1-20231024191537.commit-4091ac7 — 2023-10-24
- 1.0.1-20230929192450.commit-ed348d4 — 2023-09-29
- 1.0.1-20230914184140.commit-d2b2e35 — 2023-09-14
- 1.0.0 — 2023-09-14
- 0.1.0-20230914155248.commit-7e95d5b — 2023-09-14
- 0.1.0-20230913151216.commit-df14a43 — 2023-09-13
- 0.1.0-20230911153915.commit-fb877b5 — 2023-09-11
- 0.1.0-20230908142322.commit-6293e18 — 2023-09-08
- 0.1.0-20230908134833.commit-fee092f — 2023-09-08
- 0.1.0-20230908121338.commit-2ccb64b — 2023-09-08
- … 8 more at https://npm.io/package/@dcl/quests-client/versions

## README

<p align="center">
  <a href="https://decentraland.org">
    <img alt="Decentraland" src="https://decentraland.org/images/logo.png" width="60" />
  </a>
</p>
<h1 align="center">
  Quests Client - SDK7
</h1>

Quests Client for SDK7 is a [RPC Client](https://github.com/decentraland/rpc 'Decentraland RPC repository') which interacts with the [Quests Server](https://github.com/decentraland/quests/ 'Decentraland Quests repository') to track quests states and send events to make progress.

# Setup

If you want to contribute to this project, you will need to install the dependencies and build the project.

Start by installing NPM dependecies:

```console
$ npm install
```

The project uses the Quests Service [proto definition](./src/protocol/quests.proto) to generate the code required to compile, so before start the development, make sure you run:

```console
$ make build
```

# Usage

This library is intended to be used in a Decentraland Scene and uses SDK7 features like user authentication to initialize the client.

You can find the documentation to start using the library [here](https://docs.decentraland.org/creator/quests/sdk-client/).

## Install

Add dependency to your project

```console
$ npm add @dcl/quests-client
```

## Example

Create the Quests Client inside the `executeTask` and if the wallet based authentication is OK you will be ready to use the client to subscribe to updates or send new events that may make progress on a quest.

For this example we registered two observables to make use of the client from any other part of your code: `questEventsObservable` and `questStartObservable`

```typescript
executeTask(async () => {
  // retrieve websocket url from env
  const ws = 'wss://quests-rpc.decentraland.zone'

  const questID = 'q123-u456-e789-s012-t345'

  // create quests client
  try {
    const client = await createQuestsClient(ws, questID)

    questEventsObservable.on('message', async (action) => {
      await client.sendEvent({ action })
    })

    questStartObservable.on('start', async () => {
      await client.startQuest()
    })

    client.onStarted((quest) => {
      // update your state here or react to the quest started event
    })

    client.onUpdate((quest) => {
      // update your state here or react to the quest updates
    })

    // retrieve all quest instances and their state
    const userInstance = client.getQuestInstance()
    ...
  } catch (e) {
    console.log(`[Your Scene] connection to ${ws} failed! ${e}`)
  }
})
```

### Scene Example: Quests Tracking

In this [repository](https://github.com/decentraland/pickup-quest-scene) you may find a scene that makes use of all the Quests Client features.

Or you can go and check out the library documentation [here](https://docs.decentraland.org/creator/quests/sdk-client/)

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