# @denota-labs/denota-sdk

> SDK for Denota Protocol

Latest version **1.6.2** (published 2024-04-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install @denota-labs/denota-sdk
pnpm add @denota-labs/denota-sdk
yarn add @denota-labs/denota-sdk
bun add @denota-labs/denota-sdk
```

## 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.6.2 |
| Published | 2024-04-05 |
| First published | 2023-04-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Denota Labs |
| Maintainers | almaraz, mohamed-denota |

## Links

- npm: https://www.npmjs.com/package/@denota-labs/denota-sdk
- npm.io page: https://npm.io/package/@denota-labs/denota-sdk

## Dependencies (7)

- [axios](https://npm.io/package/axios.md) ^1.2.3
- [ethers](https://npm.io/package/ethers.md) ^5.7.0
- [graphql](https://npm.io/package/graphql.md) ^16.6.0
- [bufferutil](https://npm.io/package/bufferutil.md) ^4.0.7
- [@apollo/client](https://npm.io/package/@apollo/client.md) ^3.6.9
- [utf-8-validate](https://npm.io/package/utf-8-validate.md) ^5.0.10
- [@axelar-network/axelarjs-sdk](https://npm.io/package/@axelar-network/axelarjs-sdk.md) ^0.12.6

## Recent versions

- 1.6.2 (latest) — 2024-04-05
- 1.6.1 — 2024-03-31
- 1.6.0 — 2024-03-30
- 1.5.2 — 2024-03-28
- 1.5.1 — 2024-03-17
- 1.5.0 — 2024-03-17
- 1.4.14 — 2024-02-16
- 1.4.13 — 2024-02-14
- 1.4.12 — 2024-02-09
- 1.4.11 — 2024-02-08
- 1.4.10 — 2024-02-05
- 1.4.9 — 2024-02-02
- 1.4.8 — 2024-02-01
- 1.4.7 — 2024-01-24
- 1.4.6 — 2024-01-24
- … 23 more at https://npm.io/package/@denota-labs/denota-sdk/versions

## README

# Denota-SDK Documentation:

## Introduction:

@denota-labs/denota-sdk is a JavaScript library that allows you to send "notas," NFTs that represent escrowed tokens. The library is built using EVM blockchain technology and requires a web3 connection to function. It provides an interface to write (send), transfer, fund, cash, and approve notas. Denota is currently available on Polygon Mainnet as a beta.

## Installation:

You can install the @denota-labs/denota-sdk using the npm package manager with the following command:

```bash
npm install @denota-labs/denota-sdk
```

## Setup:

Before you can use the @denota-labs/denota-sdk, you need to set up a web3 connection. You can do this by calling the setProvider function and passing in your web3 connection. This function initializes the Ethereum provider, signer, and the contracts required to write notas.

```javascript
import { setProvider } from '@denota-labs/denota-sdk';

async function init() {
  const web3Connection = // your web3 connection here
  await setProvider(web3Connection);
}

init();
```

After setting up the web3 connection, you can use the @denota-labs/denota-sdk to write notas. 

Before sending funds, use the approveToken function to approve a token for use in writing notas.

```javascript
import { approveToken } from '@denota-labs/denota-sdk';

async function approve() {
  const currency = 'DAI';
  const approvalAmount = 100;
  await approveToken({ currency, approvalAmount });
}

approve();
```

## Direct Pay:

```javascript
import Denota from '@denota-labs/denota-sdk';

async function createNota() {
  const { txHash, notaId } = await Denota.write({
    amount: 1,
    currency: "DAI",
    module: {
      moduleName: "direct",
      type: "invoice",
      creditor: "0x...",
      debitor: "0x...",
      notes: "Example invoice",
    },
  });
}

createNota();
```

In the above code, we pass in the module object, which contains the details of the nota. We also pass in the amount and currency parameters, which represent the amount and the currency in which the nota is written.

To create an invoice, set the type property of the module object to "invoice". To send a payment, set it to "payment". Provide the Ethereum addresses of the debitor (payer) and creditor (payee). 

You can also provide optional notes or a file for the nota. If you have an IPFS hash, you can provide it using the ipfsHash property.

## Reversible Release (Escrow):

To create an escrow, set the moduleName property of the module object to "reversibleRelease" and provide the inspector property. The inspector is the party in charge of releasing or reversing the payment. If no inspector is provided, the payer is set as the inspector.  

ReversibleRelease supports the same metadata options as DirectPay.

```javascript
async function createNota() {
  const { txHash, notaId } = await Denota.write({
    amount: 1,
    currency: "DAI",
    module: {
      moduleName: "reversibleRelease",
      type: "invoice",
      inspector: "0x...",
      creditor: "0x...",
      debitor: "0x...",
      notes: "Example invoice",
    },
  });
}

createNota();
```

To release or reverse a payment, the inspector uses the cash function


```javascript
async function releaseNota() {
  const receipt = await Denota.cash({ notaId: "0", type: "release" });
}

async function reverseNota() {
  const receipt = await Denota.cash({ notaId: "0", type: "reverse" });
}
```

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