Crypto.com AI Agent SDK
  • Getting Started
    • Introduction
    • Quick Start Guide: Simulation Entry Point
  • Core Concepts Overview
    • Plugins
    • Tools
    • Blockchain Functions
      • Wallet Management
      • Token Interaction
      • Transaction Queries
      • Block Information
      • Contract Operations
      • CronosID Operations
      • Defi Operations
      • Crypto.com Exchange
    • Built-in Telegram Feature
    • Advanced Usage: Custom Instructions
    • Dynamic AI Model Manager
  • Crypto.com On-Chain Developer Platform
    • Developer Platform API Methods
  • On-Chain Functions and Examples
    • AI Agent Chatbot
    • "Magic Link" Signer
  • Resources for Developers
Powered by GitBook
On this page
  • Introduction
  • Features
  • Installation
  • Usage
  • Example Operations

Was this helpful?

Crypto.com On-Chain Developer Platform

PreviousDynamic AI Model ManagerNextDeveloper Platform API Methods

Last updated 2 months ago

Was this helpful?

Introduction

The On-Chain Developer Platform Client SDK is designed to interact seamlessly with the Crypto.com Developer Platform Service API. This client library simplifies interactions with the Cronos blockchain, supporting native tokens, ERC20 tokens, smart contracts, transactions, blocks, and wallets.

Features

Currently in beta: Expect frequent updates and potential changes in future releases.

  • Supports Cronos EVM and Cronos zkEVM.

  • Simple and intuitive API for interacting with Cronos blockchain networks.

  • Supports token balances (native & CRC20), token transfers, wrapping, and swapping.

  • Transaction queries by address or hash, and fetching transaction statuses.

  • Smart contract ABI fetching by contract address.

  • Wallet creation and balance management.

Installation

To install the package, run the following command in your project directory:

npm install @crypto.com/developer-platform-client

To install the package, run the following command:

pip install crypto-com-developer-platform-client

Usage

Configuring the Client

Here’s how you can use the Crypto.com Client for Developer Platform in your project:

First, configure the client with your API key and desired blockchain network (Cronos EVM or Cronos ZK EVM):

import { Client, CronosZkEvm } from '@crypto.com/developer-platform-client';

Client.init({
  chain: CronosZkEvm.Testnet, // Or CronosEvm.Mainnet for mainnet
  apiKey: 'YOUR_API_KEY', // Explorer API
  provider: 'https://provider-url.com', // Optional provider URL for signing
});
from crypto-com-developer-platform-client import Block, Client
from crypto-com-developer-platform-client.interfaces.chain_interfaces import CronosZkEvm


Client.init(api_key="EXPLORER_API_KEY",
            chain_id=CronosZkEvm.TESTNET,provider="YOUR_PROVIDER")

block = Block.get_by_tag("latest")

Example Operations

Wallet Operations

  • Create a Wallet:

const wallet = await Wallet.create();
console.log(wallet);
  • Get Wallet Balance:

const balance = await Wallet.balance('0xYourWalletAddress');
console.log(balance);

Token Operations

  • Fetch Native Token Balance:

const nativeBalance = await Token.getNativeTokenBalance('0xYourWalletAddress');
console.log(nativeBalance);
  • Fetch ERC20 Token Balance:

const erc20Balance = await Token.getERC20TokenBalance('0xYourWalletAddress', '0xErc20ContractAddress');
console.log(erc20Balance);
  • Transfer Tokens:

const transferResult = await Token.transfer({
  to: '0xRecipientAddress',
  amount: 10, // Amount of tokens to transfer
});
console.log(transferResult);
  • Wrap Tokens:

const wrapResult = await Token.wrap({
  fromContractAddress: '0xOriginalTokenAddress',
  toContractAddress: '0xWrappedTokenAddress',
  amount: 10,
});
console.log(wrapResult);
  • Swap Tokens:

const swapResult = await Token.swap({
  fromContractAddress: '0xOriginalTokenAddress',
  toContractAddress: '0xSwappedTokenAddress',
  amount: 10,
});
console.log(swapResult);

Transaction Operations

  • Fetch Transactions by Address:

const transactions = await Transaction.getTransactionsByAddress('0xYourWalletAddress');
console.log(transactions);
  • Fetch Transaction by Hash:

const transaction = await Transaction.getTransactionByHash('0xTransactionHash');
console.log(transaction);
  • Get Transaction Status:

const status = await Transaction.getTransactionStatus('0xTransactionHash');
console.log(status);

Contract Operations

  • Fetch Contract ABI by Address:

const abi = await Contract.getContractABI('0xContractAddress');
console.log(abi);

Block Operations

  • Fetch Block by Tag or Block Number:

const block = await Block.getBlockByTag('latest'); // Can use 'latest', 'earliest', or a specific block number
console.log(block);

Coming soon


Crypto.com