The Crypto.com Developer Platform Client.ts is a TypeScript/JavaScript SDK designed to interact with the Crypto.com Developer Platform Service API. This client simplifies working with the Cronos blockchain, covering native tokens, ERC20/ERC721 tokens, smart contracts, DeFi, exchange, and transaction services.
- Native and ERC20/ERC721 token operations
- Token transfers, wrapping, swapping
- Contract ABI and bytecode fetching
- Cronos ID (name ↔ address resolution)
- Blockchain transactions and block data
- DeFi protocols (farms, whitelisted tokens)
- Crypto.com exchange data
- Supports Cronos EVM and Cronos ZK EVM
npm install @crypto.com/developer-platform-clientHere’s how you can use the Crypto.com Developer Platform Client.ts in your project:
First, initialize the client with your API key. To get an API Key, please create an account and a project at https://developer.crypto.com.
import { Client, CronosZkEvm } from '@crypto.com/developer-platform-client'; Client.init({ apiKey: 'YOUR_API_KEY', provider: 'https://your-provider-url.com', // Optional });const wallet = await Wallet.create(); console.log(wallet);const balance = await Wallet.balance('0xYourWallet'); console.log(balance);const native = await Token.getNativeTokenBalance('0xYourWallet'); console.log(native);const erc20 = await Token.getERC20TokenBalance('0xYourWallet', '0xToken'); console.log(erc20);const transfer = await Token.transfer({ to: '0xRecipient', amount: 5 }); console.log(transfer);const wrap = await Token.wrap({ amount: 10 }); console.log(wrap);const swap = await Token.swap({ fromContractAddress: '0xFrom', toContractAddress: '0xTo', amount: 2, }); console.log(swap);const balance721 = await Token.getERC721TokenBalance('0xYourWallet', '0xERC721Contract'); console.log(balance721);const owner = await Token.getTokenOwner('0xERC721Contract', '1'); console.log(owner);const uri = await Token.getTokenURI('0xERC721Contract', '1'); console.log(uri);const metadata721 = await Token.getERC721Metadata('0xERC721Contract'); console.log(metadata721);const metadata20 = await Token.getERC20Metadata('0xERC20Contract'); console.log(metadata20);const tx = await Transaction.getTransactionByHash('0xHash'); console.log(tx);const status = await Transaction.getTransactionStatus('0xHash'); console.log(status);const count = await Transaction.getTransactionCount('0xWallet'); console.log(count);const gasPrice = await Transaction.getGasPrice(); console.log(gasPrice);const fee = await Transaction.getFeeData(); console.log(fee);const estimate = await Transaction.estimateGas({ from: '0xFrom', to: '0xTo', value: '0xValue', data: '0xData', }); console.log(estimate);const bytecode = await Contract.getContractCode('0xContract'); console.log(bytecode);const current = await Block.getCurrentBlock(); console.log(current);const block = await Block.getBlockByTag('latest'); console.log(block);const resolved = await CronosId.forwardResolve('alice.cro'); console.log(resolved);const reverse = await CronosId.reverseResolve('0xYourWallet'); console.log(reverse);const tokens = await Defi.getWhitelistedTokens(DefiProtocol.H2); console.log(tokens);const farms = await Defi.getAllFarms(DefiProtocol.VVS); console.log(farms);const farm = await Defi.getFarmBySymbol(DefiProtocol.H2, 'zkCRO-MOON'); console.log(farm);const all = await Exchange.getAllTickers(); console.log(all);const ticker = await Exchange.getTickerByInstrument('BTC_USDT'); console.log(ticker);Client.init(config): Initializes the client with an API key, chain, and optional provider.Client.getApiKey(): Returns the currently configured API key.Client.getProvider(): Returns the configured provider URL.Client.getChainId(): Returns the selected chain ID.
Wallet.create(): Creates a new wallet and returns its address, private key, and mnemonic.Wallet.balance(address): Fetches the native token balance for a wallet address.
Token.getNativeTokenBalance(address): Returns the native token balance for a given wallet or CronosId.Token.getERC20TokenBalance(address, contractAddress, blockHeight?): Returns the ERC20 token balance.Token.transfer({ to, amount, contractAddress? }): Transfers native or ERC20 tokens.Token.wrap({ amount }): Wraps tokens.Token.swap({ fromContractAddress, toContractAddress, amount }): Swaps tokens.Token.getERC721TokenBalance(address, contractAddress): Returns ERC721 token balance.Token.getTokenOwner(contractAddress, tokenId): Returns the owner of a specific ERC721 token.Token.getTokenURI(contractAddress, tokenId): Returns the token URI of an ERC721 token.Token.getERC721Metadata(contractAddress): Returns metadata for an ERC721 contract.Token.getERC20Metadata(contractAddress): Returns metadata for an ERC20 contract.
Transaction.getTransactionByHash(txHash): Returns a transaction by hash.Transaction.getTransactionStatus(txHash): Returns transaction status.Transaction.getTransactionCount(address): Returns the nonce/transaction count for a wallet.Transaction.getGasPrice(): Returns the current gas price.Transaction.getFeeData(): Returns fee-related data.Transaction.estimateGas(payload): Estimates the gas for a transaction.
Contract.getContractCode(contractAddress): Returns bytecode of a smart contract.
Block.getCurrentBlock(): Returns the latest block.Block.getBlockByTag(tag, txDetail?): Fetches block by tag or number.
CronosId.forwardResolve(cronosId): Resolves a CronosId to a wallet address.CronosId.reverseResolve(address): Resolves an address to its CronosId (if any).
Defi.getWhitelistedTokens(protocol): Returns whitelisted tokens for a protocol.Defi.getAllFarms(protocol): Returns all farms for a protocol.Defi.getFarmBySymbol(protocol, symbol): Returns farm details by symbol.
Exchange.getAllTickers(): Returns all market tickers.Exchange.getTickerByInstrument(instrumentName): Returns market data for a given trading pair.
The SDK supports both Cronos EVM and Cronos ZK EVM networks.
CronosEvm.Mainnet; // Chain ID: 25 CronosEvm.Testnet; // Chain ID: 338 CronosZkEvm.Mainnet; // Chain ID: 388 CronosZkEvm.Testnet; // Chain ID: 240This project is licensed under the MIT License.
If you have any questions or comments about the library, please feel free to open an issue or a pull request on our GitHub repository.