Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

caip

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caip

CAIP standard utils

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6K
decreased by-50.48%
Maintainers
1
Weekly downloads
 
Created
Source

caip npm version

CAIP standard utils

ChainID (CAIP-2)

Using Classes

import { ChainID } from "caip";

const chainId = new ChainID("eip155:1");

// OR

const chainId = new ChainID({ namespace: "eip155", reference: "1" });

// THEN

chainId.toString();
// "eip155:1"

chainId.toJson();
// { namespace: "eip155", reference: "1" }

Using Functions

import { ChainID } from "caip";

ChainID.parse("eip155:1");
// { namespace: "eip155", reference: "1" }

// AND

ChainID.format({ namespace: "eip155", reference: "1" });
// "eip155:1"

AccountID (CAIP-10)

Using Classes

import { AccountID } from "caip";

const accountId = new AccountID(
  "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"
);

// OR

const accountId = new AccountID({
  address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
  chainId: { namespace: "eip155", reference: "1" },
});

// THEN

accountId.toString();
// "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"

accountId.toJson();
// { address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb", chainId: { namespace: "eip155", reference: "1" } }

Using Functions

import { ChainID } from "caip";

ChainID.parse("0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1");
// { address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb", chainId: { namespace: "eip155", reference: "1" } }

// AND

ChainID.format({
  address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
  chainId: { namespace: "eip155", reference: "1" },
});
//"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"

Keywords

FAQs

Package last updated on 24 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc