
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@cedra-labs/ts-sdk
Advanced tools
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!
tsconfig.json
uses "moduleResolution": "node"
Network | RPC Endpoint | Chain ID | Faucet |
---|---|---|---|
Testnet | https://testnet.cedra.dev/v1 | TBD | Available via CLI |
Mainnet | Coming Soon | TBD | N/A |
Devnet | https://devnet.cedra.dev/v1 | TBD | Available via CLI |
Install with your favorite package manager such as npm, yarn, or pnpm:
pnpm install @cedra-labs/ts-sdk
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
.
Follow these steps to connect to Cedra blockchain and make your first transaction:
npm install @cedra-labs/ts-sdk
# or
yarn add @cedra-labs/ts-sdk
# or
pnpm install @cedra-labs/ts-sdk
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);
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
});
See the complete example in the Submit transaction section below.
// 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" });
Learn more from the official Cedra documentation:
If you see import errors, ensure your tsconfig.json
uses:
{
"compilerOptions": {
"moduleResolution": "node"
}
}
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.We welcome contributions! Please:
For questions or support, join our Discord community.
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
Cedra TypeScript SDK
We found that @cedra-labs/ts-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.