open-index/open-npm huggingface dataset:
npm package: @riaskov/iohtee
Description: Micropayments lib for EVM
Author: Sergey Ukustov
Latest version: 3.0.0

# @riaskov/iohtee

Micropayments library for EVM chains (ETH and token channels) over HTTP.

## Stack

- Node.js `>=22`
- TypeScript `6.0.0-beta` (strict)
- `viem` `2.45.0`
- Storage backends: `sqlite://` and `postgres://` / `postgresql://`

## Install

```bash
pnpm add @riaskov/iohtee
```

## Constructor (current API)

```ts
import { IohTee } from '@riaskov/iohtee'

const client = new IohTee({
  networkId: 80002,
  httpRpcUrl: process.env.RPC_URL!,
  mnemonic: process.env.ACCOUNT_MNEMONIC!,
  hdPath: "m/44'/60'/0'/0/0",
  options: {
    databaseUrl: 'sqlite:///absolute/path/to/iohtee.db',
  },
})
```

`web3`-style constructor is not supported anymore.

## Minimal flow

```ts
import { IohTee } from '@riaskov/iohtee'

const iohtee = new IohTee({
  networkId: 80002,
  httpRpcUrl: process.env.RPC_URL!,
  mnemonic: process.env.ACCOUNT_MNEMONIC!,
  hdPath: "m/44'/60'/0'/0/0",
})

const result = await iohtee.buy({
  receiver: '0x0000000000000000000000000000000000000001',
  price: 1000n,
  gateway: 'http://127.0.0.1:3001/accept',
  meta: 'purchase-1',
})

console.log(result.token, result.channelId)
await iohtee.shutdown()
```

## Public API highlights

- `buy(options)`
- `buyUrl(uri)`
- `payment(options)`
- `open(receiver, value, channelId?, tokenContract?)`
- `deposit(channelId, value)`
- `close(channelId)`
- `acceptPayment(req)`
- `acceptToken(req)`
- `channels()`, `openChannels()`, `settlingChannels()`, `channelById(id)`
- `paymentById(id)`
- `publicClient()`, `walletClient()`
- `shutdown()`

## Scripts (package development)

```bash
pnpm --filter @riaskov/iohtee run lint
pnpm --filter @riaskov/iohtee run test
pnpm --filter @riaskov/iohtee run build
```

## Notes

- `nedb` support removed.
- Use absolute sqlite path: `sqlite:///abs/path.db`.
npm package: @riaskov/iohtee-contracts
Description: IohTee contracts managed by Hardhat
Author: Sergey Ukustov
Latest version: 6.1.0

# @riaskov/iohtee-contracts

Smart contracts and TypeScript bindings for IohTee, built with Hardhat 3.

## Stack

- Node.js `>=22`
- Hardhat `3`
- Solidity `0.8.28` (`evmVersion: cancun`, optimizer enabled)
- `viem` toolchain
- OpenZeppelin Contracts `5.0.2`

## Contracts

Key contracts in `contracts/`:

- `Unidirectional.sol`
- `TokenUnidirectional.sol`
- `UnidirectionalUpgradeable.sol`
- `TokenUnidirectionalUpgradeable.sol`
- `UUPSProxy.sol`
- `UnidirectionalUpgradeableV2.sol` (upgrade example)

## Build and test

```bash
pnpm --filter @riaskov/iohtee-contracts run compile
pnpm --filter @riaskov/iohtee-contracts run test
pnpm --filter @riaskov/iohtee-contracts run build
pnpm --filter @riaskov/iohtee-contracts run coverage
```

## Deploy (Ignition)

Local hardhat node:

```bash
pnpm --filter @riaskov/iohtee-contracts run hardhat:node
```

Deploy modules:

```bash
pnpm --filter @riaskov/iohtee-contracts run deploy:local
pnpm --filter @riaskov/iohtee-contracts run deploy:uni:hardhat
pnpm --filter @riaskov/iohtee-contracts run deploy:uni:polygonAmoy
pnpm --filter @riaskov/iohtee-contracts run deploy:uni:uups:hardhat
pnpm --filter @riaskov/iohtee-contracts run deploy:uni:uups:polygonAmoy
pnpm --filter @riaskov/iohtee-contracts run deploy:token:uups:hardhat
pnpm --filter @riaskov/iohtee-contracts run deploy:token:uups:polygonAmoy
```

## Environment

Common variables:

- `ACCOUNT_PRIVATE_KEY_0`
- `POLYGON_RPC_URL`
- `POLYGON_AMOY_RPC_URL`

## Security notes

Upgradeable contracts use UUPS pattern with:

- initializer-based setup
- `_disableInitializers()` on implementation constructors
- owner-gated `_authorizeUpgrade`
- pausability and reentrancy protections in critical flows