# @finmath.net/sdc

> Solidity Smart Derivative Contracts

Latest version **0.9.0** (published 2026-11-19) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install @finmath.net/sdc
pnpm add @finmath.net/sdc
yarn add @finmath.net/sdc
bun add @finmath.net/sdc
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2026-11-19 |
| First published | 2024-08-02 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 324.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Christian Fries, Peter Kohl-Landgraf, Alexandros Korpis |
| Maintainers | finmath.net |
| Keywords | Smart Derivative Contract, SDC, EIP-6123, ERC-6123 |

## Links

- npm: https://www.npmjs.com/package/@finmath.net/sdc
- Repository: https://github.com/finmath/ERCs
- Homepage: https://github.com/finmath/ERCs/tree/master/assets/erc-6123#readme
- Issues: https://github.com/finmath/ERCs/issues
- npm.io page: https://npm.io/package/@finmath.net/sdc

## Dependencies (1)

- [@openzeppelin/contracts](https://npm.io/package/@openzeppelin/contracts.md) 5.0.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.9.0 (latest) — 2026-11-19
- 0.8.0 — 2025-09-26
- 0.5.0 — 2025-01-27
- 0.4.4 — 2024-11-10
- 0.4.2 — 2024-08-08
- 0.4.1 — 2024-08-02

## README

# SDC Solidity implementation

## Description

The reference SDC implementation can be unit tested with Hardhat to understand the trade process logic.

The trade interface takes explicit participants. Inception returns a generated
trade ID that is never reused; confirmation and cancellation repeat it with the
original parties, signed amounts and text fields. Termination methods also identify
the requester and retain that requester's payment perspective.

The SDC and FX spot trade examples require direct calls from the participant responsible for each
action. This authorization policy is specific to the examples, not part of ERC-6123.
The build uses Solidity 0.8.24.

`FxSpotTrade` represents an FX spot trade with atomic payment-versus-payment (PvP)
settlement. Confirmation exchanges the two currency-token amounts once through a
shared `ERC20PvPSettlementRouter`. Parties approve the router before confirmation.

These implementations illustrate the protocol. `ERC20Settlement` allows unrestricted
`mint` and `setSDCAddress` calls, and `SDCSingleTradePledgedBalance.performSettlement`
does not authenticate the valuation provider. Applications must define and enforce
those permissions before using these examples with real assets.

### Compile and run tests with Hardhat

We provide the essential steps to compile the contracts and run the provided unit tests.

### Provided Contracts and Tests

#### Interfaces

- `contracts/ISDC.sol` - Interface contract (aggregation of `ISDCTrade`, `ISDCSettlement`, `IAsyncTransferCallback`)
- `contracts/ISDCTrade.sol` - Interface related to trade incept/confirm/terminate
- `contracts/ISDCSettlement.sol` - Interface related to settlement initiate/perform/after
- `contracts/IAsyncTransferCallback.sol` - Interface related to transfer.

- `contracts/IAsyncTransfer.sol` - Interface (extending the ERC-20) for settlement tokens used in `SDCPledgedBalance`.

#### Implementations

- `contracts/TradeIdGenerator.sol` - Generates decimal trade identifiers that are never reused

- `contracts/SDCSingleTrade.sol` - SDC abstract contract for an OTC Derivative (single trade case only)
- `contracts/SDCSingleTradePledgedBalance.sol` - SDC full implementation for an OTC Derivative (single trade case only)
- `contracts/ERC20Settlement.sol` - Mintable settlement token contract implementing `IERC20Settlement` for unit tests
- `contracts/examples/FxSpotTrade/FxSpotTrade.sol` - FX spot trade with atomic PvP settlement
- `contracts/examples/FxSpotTrade/FxSpotTradeFactory.sol` - Creates trades and registers them with the shared router
- `contracts/examples/FxSpotTrade/ERC20PvPSettlementRouter.sol` - Settles both token legs atomically using shared token allowances

#### Tests

- `test/SDCTests.js` - Unit tests for the life-cycle of the sdc implementation
- `test/TradeContextTest.js` - Explicit participants, exact matching and trade ID replay checks
- `test/FxSpotTradeTest.js` - FX settlement, exact matching and single-use lifecycle checks

### Compile and run tests with Hardhat

Install dependencies:
```shell
npm i
```

Compile:
```shell
npx hardhat compile
```

Run all tests:
```shell
npx hardhat test
```

### Configuration files

- `package.json` - JavaScript package definition.
- `hardhat.config.js` - Hardhat config.

### Used javascript-based testing libraries for solidity

- `ethereum-waffle`: Waffle is a Solidity testing library. It allows you to write tests for your contracts with JavaScript.
- `chai`: Chai is an assertion library and provides functions like expect.
- `ethers`: This is a popular Ethereum client library. It allows you to interface with blockchains that implement the Ethereum API.
- `solidity-coverage`: This library gives you coverage reports on unit tests with the help of Istanbul.

### Packaging

The npm package is built from `assets/erc-6123` in the ERCs repository.
Run `npm pack --dry-run` from this directory to inspect its contents. Contracts,
documentation, tests and configuration are included; generated build and coverage
files are excluded.

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