Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcspark/cip34-js
https://github.com/dcspark/cip34-js
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/dcspark/cip34-js
- Owner: dcSpark
- License: apache-2.0
- Created: 2021-12-13T15:26:46.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T21:16:30.000Z (3 months ago)
- Last Synced: 2024-11-14T11:49:28.498Z (about 2 months ago)
- Language: TypeScript
- Size: 605 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CIP34-JS
A JS library for [CIP34](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0034) that defines chain IDs for Cardano.
## Example
| Network name | CIP34 chain ID |
| ------------- | ----------------- |
| PreProduction | cip34:0-1 |
| Mainnet | cip34:1-764824073 |## Usage
Generate chain ID from registry data
```typescript
import { toChainId } from "@dcspark/cip34-js";
import registry from "@dcspark/cip34-js/registry";const chainId = toChainId({
networkId: registry.Mainnet.NetworkId,
networkMagic: registry.Mainnet.NetworkMagic,
});
```Get parts from chain ID
```typescript
import { fromChainId } from "@dcspark/cip34-js";const { networkId, networkMagic } = fromChainId(chainId);
```## Updating
The current status of the registry is tracked inside the CIP repository. To keep things in sync, this project uses the CIP repo as a git submodule.
To use the latest version of the registry,
1. `git submodule init`
2. `git submodule update`
3. (whenever you want to update afterwards) `npm run update-submodule`