Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@cedra-labs/ts-sdk

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cedra-labs/ts-sdk

Cedra TypeScript SDK

latest
npmnpm
Version
2.2.5
Version published
Maintainers
1
Created
Source

TypeScript SDK for Cedra

License Discord NPM Package Version Node Version NPM bundle size NPM Package Downloads

The TypeScript SDK allows you to connect, explore, and interact with the Cedra blockchain. You can use it to request data, send transactions, set up test environments, and more!

Prerequisites

  • Node.js: Version 16.0 or higher
  • npm/yarn/pnpm: A package manager for installing dependencies
  • TypeScript (optional): For TypeScript projects, ensure your tsconfig.json uses "moduleResolution": "node"

Network Information

NetworkRPC EndpointChain IDFaucet
Testnethttps://testnet.cedra.dev/v1TBDAvailable via CLI
MainnetComing SoonTBDN/A
Devnethttps://devnet.cedra.dev/v1TBDAvailable via CLI

Installation

For use in Node.js or a web application

Install with your favorite package manager such as npm, yarn, or pnpm:

pnpm install @cedra-labs/ts-sdk

For use in a browser (<= version 1.9.1 only)

You can add the SDK to your web application using a script tag:

<script src="https://unpkg.com/@cedra-labs/ts-sdk/dist/browser/index.global.js"></script>

Then, the SDK can be accessed through window.cedraSDK.

Quick Start for Newcomers

Follow these steps to connect to Cedra blockchain and make your first transaction:

Step 1: Install the SDK

npm install @cedra-labs/ts-sdk
# or
yarn add @cedra-labs/ts-sdk
# or
pnpm install @cedra-labs/ts-sdk

Step 2: Connect to the Network

Create an Cedra client to connect to the blockchain:

import { Cedra, CedraConfig, Network } from "@cedra-labs/ts-sdk"

// You can use CedraConfig to choose which network to connect to
const config = new CedraConfig({ network: Network.TESTNET });
// Cedra is the main entrypoint for all functions
const cedra = new Cedra(config);

// Verify connection
const ledgerInfo = await cedra.getLedgerInfo();
console.log("Connected to Cedra blockchain!");
console.log("Chain ID:", ledgerInfo.chain_id);
console.log("Latest block:", ledgerInfo.block_height);

Step 3: Create Your First Account

import { Account } from "@cedra-labs/ts-sdk";

// Generate a new account
const account = Account.generate();
console.log("New account address:", account.accountAddress);

// Fund it with test tokens
await cedra.fundAccount({
  accountAddress: account.accountAddress,
  amount: 100_000_000, // 1 CEDRA
});

Step 4: Send Your First Transaction

See the complete example in the Submit transaction section below.

Reading Data From Onchain

// Check account balance
const accountInfo = await cedra.getAccountInfo({ accountAddress: "0x123" });
console.log("Account balance:", accountInfo.coin.value);

// Get account modules
const modules = await cedra.getAccountModules({ accountAddress: "0x123" });

// Get owned tokens
const tokens = await cedra.getAccountOwnedTokens({ accountAddress: "0x123" });

// Get recent transactions
const transactions = await cedra.getAccountTransactions({ accountAddress: "0x123" });

Next Steps

Learn more from the official Cedra documentation:

Troubleshooting

TypeScript Import Errors

If you see import errors, ensure your tsconfig.json uses:

{
  "compilerOptions": {
    "moduleResolution": "node"
  }
}

Connection Issues

  • Timeout errors: Increase timeout in CedraConfig or check network connectivity
  • Rate limiting: Implement exponential backoff for retries
  • Invalid endpoint: Verify you're using the correct network endpoint

Common Errors

  • INSUFFICIENT_BALANCE: Account needs more tokens. Use the faucet on testnet.
  • SEQUENCE_NUMBER_MISMATCH: Transaction ordering issue. Fetch latest account state.
  • MODULE_NOT_FOUND: Smart contract not deployed at specified address.

Contributing

We welcome contributions! Please:

  • Check existing issues or create a new one to discuss your idea
  • Fork the repository and create a pull request
  • Follow our contributing guidelines

For questions or support, join our Discord community.

Running unit tests

To run a unit test in this repo, for example, the keyless end-to-end unit test in tests/e2e/api/keyless.test.ts:

pnpm jest keyless.test.ts

FAQs

Package last updated on 25 Sep 2025

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