caip
CAIP standard utils
ChainID (CAIP-2)
Using Classes
import { ChainID } from "caip";
const chainId = new ChainID("eip155:1");
const chainId = new ChainID({ namespace: "eip155", reference: "1" });
chainId.toString();
chainId.toJson();
Using Functions
import { ChainID } from "caip";
ChainID.parse("eip155:1");
ChainID.format({ namespace: "eip155", reference: "1" });
AccountID (CAIP-10)
Using Classes
import { AccountID } from "caip";
const accountId = new AccountID(
"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"
);
const accountId = new AccountID({
address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
chainId: { namespace: "eip155", reference: "1" },
});
accountId.toString();
accountId.toJson();
Using Functions
import { ChainID } from "caip";
ChainID.parse("0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1");
ChainID.format({
address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
chainId: { namespace: "eip155", reference: "1" },
});