# @hyperledger/cactus-plugin-htlc-coordinator-besu

> HTLC Coordinator to exchange tokens between networks.

Latest version **2.0.0** (published 2024-10-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @hyperledger/cactus-plugin-htlc-coordinator-besu
pnpm add @hyperledger/cactus-plugin-htlc-coordinator-besu
yarn add @hyperledger/cactus-plugin-htlc-coordinator-besu
bun add @hyperledger/cactus-plugin-htlc-coordinator-besu
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-10-18 |
| First published | 2021-11-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 17 |
| Unpacked size | 250.6 KB |
| Known vulnerabilities | 0 (+42 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 412 |
| Author | Hyperledger Cactus Contributors |
| Maintainers | hyperledger-ghci, hyperledger-lf |
| Keywords | Hyperledger, Cactus, Integration, Blockchain, Distributed Ledger Technology |

## Links

- npm: https://www.npmjs.com/package/@hyperledger/cactus-plugin-htlc-coordinator-besu
- Repository: https://github.com/hyperledger/cacti
- Homepage: https://github.com/hyperledger/cacti#readme
- Issues: https://github.com/hyperledger-cacti/cacti/issues
- npm.io page: https://npm.io/package/@hyperledger/cactus-plugin-htlc-coordinator-besu

## Dependencies (17)

- [joi](https://npm.io/package/joi.md) 17.13.3
- [uuid](https://npm.io/package/uuid.md) 10.0.0
- [axios](https://npm.io/package/axios.md) 1.7.7
- [body-parser](https://npm.io/package/body-parser.md) 1.20.3
- [prom-client](https://npm.io/package/prom-client.md) 15.1.3
- [openapi-types](https://npm.io/package/openapi-types.md) 12.1.3
- [run-time-error-cjs](https://npm.io/package/run-time-error-cjs.md) 1.4.0
- [fast-safe-stringify](https://npm.io/package/fast-safe-stringify.md) 2.1.1
- [typescript-optional](https://npm.io/package/typescript-optional.md) 2.0.1
- [@hyperledger/cactus-core](https://npm.io/package/@hyperledger/cactus-core.md) 2.0.0
- [@hyperledger/cactus-common](https://npm.io/package/@hyperledger/cactus-common.md) 2.0.0
- [@hyperledger/cactus-core-api](https://npm.io/package/@hyperledger/cactus-core-api.md) 2.0.0
- [socket.io-client-fixed-types](https://npm.io/package/socket.io-client-fixed-types.md) 4.5.4
- [@hyperledger/cactus-plugin-htlc-eth-besu](https://npm.io/package/@hyperledger/cactus-plugin-htlc-eth-besu.md) 2.0.0
- [@hyperledger/cactus-plugin-htlc-eth-besu-erc20](https://npm.io/package/@hyperledger/cactus-plugin-htlc-eth-besu-erc20.md) 2.0.0
- [@hyperledger/cactus-plugin-ledger-connector-besu](https://npm.io/package/@hyperledger/cactus-plugin-ledger-connector-besu.md) 2.0.0
- [@hyperledger/cactus-test-plugin-htlc-eth-besu-erc20](https://npm.io/package/@hyperledger/cactus-test-plugin-htlc-eth-besu-erc20.md) 2.0.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-10-18
- 2.0.0-main.339 (main) — 2024-06-13
- 2.0.0-2945-supply-chain-app-build-failed.241 (2945-supply-chain-app-build-failed) — 2024-03-08
- 2.0.0-lfx-connector.208 (lfx-connector) — 2024-02-07
- 2.0.0-dev.197 (dev) — 2024-01-25
- 2.0.0-build-deps-upgrade-to-lerna-lite-v3-1-0-config-fix.126 (build-deps-upgrade-to-lerna-lite-v3-1-0-config-fix) — 2023-12-08
- 1.0.1-jwt-supply-chain.9df3fe79.16 (jwt-supply-chain) — 2022-04-05
- 2.0.0-rc.7 — 2024-10-02
- 2.0.0-rc.2 — 2024-07-04
- 2.0.0-rc.1 — 2024-06-18
- 2.0.0-main.214 — 2024-02-15
- 2.0.0-dev.196 — 2024-01-25
- 2.0.0-dev.195 — 2024-01-24
- 2.0.0-lfx-connector.164 — 2024-01-16
- 2.0.0-lfx-connector.163 — 2024-01-16
- … 15 more at https://npm.io/package/@hyperledger/cactus-plugin-htlc-coordinator-besu/versions

## README

# `@hyperledger/cactus-plugin-htlc-coordinator-besu`

Allows Cactus nodes to interact beetwen diferent networks. Using this we can perform:
* Instantiate an existing HTLC plugin, also the own HTLC and the counterparty HTLC.
* Interact with the HTLC, deploying, checking and withdrawing the funds.
## Summary

  - [Usage](#usage)
  - [Development](#development)
    - [Getting Started](#getting-started)
    - [Flow](#flow)
  - [Contributing](#contributing)
  - [License](#license)
  - [Acknowledgments](#acknowledgments)

## Usage

To use this import public-api and create new **PluginFactoryHTLCCoordinatorBesu*. Then use it to create a HTLC Coordinator.
```typescript
    const factoryHTLC = new PluginFactoryHTLCCoordinatorBesu({
        pluginImportType: PluginImportType.Local,
    });
    const pluginHTLCCoordinatorBesu = await factoryHTLC.create(pluginOptions);
```
You can make calls through the htlc coordinator to the plugin API:

```typescript
async ownHTLC(ownHTLCRequest: OwnHTLCRequest): Promise<InvokeContractV1Response>; 
async counterpartyHTLC(counterpartyHTLCRequest: CounterpartyHTLCRequest): Promise<InvokeContractV1Response>;
async withdrawCounterparty(withdrawCounterpartyRequest: WithdrawCounterpartyRequest): Promise<InvokeContractV1Response>;
```

Call example to create an ownHTLC and instantiate a HTLC contract:
```typescript
    const ownHTLCRequest: OwnHTLCRequest = {
        htlcPackage: HtlcPackage.BesuErc20,
        connectorInstanceId,
        keychainId,
        constructorArgs: [],
        web3SigningCredential,
        inputAmount: 10,
        outputAmount: 1,
        expiration,
        hashLock,
        tokenAddress,
        receiver,
        outputNetwork: "BTC",
        outputAddress: "1AcVYm7M3kkJQH28FXAvyBFQzFRL6xPKu8",
        gas: estimatedGas,
    };
    const response = await coordinator.ownCoordinator(ownHTLCRequest);
});
```
The field "htlcPackage" can have the following values:
```typescript
    enum HtlcPackage {
        Besu = 'BESU',
        BesuErc20 = 'BESU_ERC20'
    }
```

## Development

### Getting Started

Clone the git repository on your local machine. Follow these instructions that will get you a copy of the project up and running on
your local machine for development and testing purposes.

#### Prerequisites

In the root of the project to install the dependencies execute the command:
```sh
yarn run configure
```

#### Compiling

In the project root folder, run this command to compile the plugin and create the dist directory:
```sh
yarn run watch
```

### Flow

#### Alice flow

The [Alice diagram](docs/flow/htlc-coordinator-alice-flow.md, "Alice Flow") shows the sequence diagram of a complete flow for a participant who wants exchange funds with another participant. She doesn't start the withdraw flow becuase she doesn't know the secret to withdraw them.

#### Bob flow

The next [Bob diagram](docs/flow/htlc-coordinator-bob-flow.md, "Bob Flow") 
shows the sequence diagram of a complete flow for a participant who wants exchange funds with another participant, but he knows the secret and starts the flow to withdraw the funds.


## Contributing

We welcome contributions to Hyperledger Cactus in many forms, and there’s always plenty to do!

Please review [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.

## License

This distribution is published under the Apache License Version 2.0 found in the [LICENSE](../../LICENSE) file.

---
_Source: https://npm.io/package/@hyperledger/cactus-plugin-htlc-coordinator-besu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
