A python client to interact with @cryptocom/developer-platform-service
Project description
Crypto.com Developer Platform Client.py
The Crypto.com Developer Platform Client.py is a Python SDK for integrating with the Crypto.com Developer Platform Service API. It simplifies access to blockchain features across the Cronos ecosystem (Cronos EVM & Cronos ZK EVM), covering native & ERC20 tokens, smart contracts, DeFi, wallets, transactions, and more.
Features
- Blockchain interaction for Cronos EVM & ZK EVM chains
- Native and ERC20/ERC721 token operations
- Smart contract ABI & bytecode querying
- Cronos ID forward/reverse resolution
- Transactions, blocks, and fee utilities
- DeFi protocols: farms, tokens
- Exchange ticker data
Installation
pip install crypto-com-developer-platform-client
Initialize the Client
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.
from crypto_com_developer_platform_client import Client
from crypto_com_developer_platform_client.interfaces.chain_interfaces import CronosZkEvm
Client.init(
api_key="YOUR_EXPLORER_API_KEY",
provider="https://your-provider.com" # Optional
)
Wallet
from crypto_com_developer_platform_client import Wallet
wallet = Wallet.create()
print(wallet)
balance = Wallet.get_balance("0xYourWalletAddress")
print(balance)
Token
from crypto_com_developer_platform_client import Token
native_balance = Token.get_native_balance("0xYourWalletAddress")
print(native_balance)
erc20_balance = Token.get_erc20_balance("0xYourWallet", "0xTokenContract")
print(erc20_balance)
result = Token.transfer_token("0xRecipient", 10)
print(result)
wrap = Token.wrap_token("0xFromContract", "0xToContract", "0xReceiver", 5)
print(wrap)
swap = Token.swap_token("0xFrom", "0xTo", "0xReceiver", 3)
print(swap)
Transaction
from crypto_com_developer_platform_client import Transaction
tx = Transaction.get_transaction_by_hash("0xTxHash")
print(tx)
status = Transaction.get_transaction_status("0xTxHash")
print(status)
count = Transaction.get_transaction_count("0xWallet")
print(count)
gas_price = Transaction.get_gas_price()
print(gas_price)
fee = Transaction.get_fee_data()
print(fee)
estimate = Transaction.estimate_gas({
"from": "0xFromAddress",
"to": "0xToAddress",
"value": "0xAmountInHex"
})
print(estimate)
Contract
from crypto_com_developer_platform_client import Contract
bytecode = Contract.get_contract_code("0xContractAddress")
print(bytecode)
Block
from crypto_com_developer_platform_client import Block
current = Block.get_current_block()
print(current)
block = Block.get_by_tag("latest", tx_detail="true")
print(block)
Cronos ID
from crypto_com_developer_platform_client import CronosId
resolved = CronosId.forward_resolve("alice.cro")
print(resolved)
reverse = CronosId.reverse_resolve("0xAddress")
print(reverse)
DeFi
from crypto_com_developer_platform_client import Defi
from crypto_com_developer_platform_client.interfaces.defi_interfaces import DefiProtocol
tokens = Defi.get_whitelisted_tokens(DefiProtocol.H2)
print(tokens)
farms = Defi.get_all_farms(DefiProtocol.VVS)
print(farms)
farm = Defi.get_farm_by_symbol(DefiProtocol.H2, "zkCRO-MOON")
print(farm)
Exchange
from crypto_com_developer_platform_client import Exchange
tickers = Exchange.get_all_tickers()
print(tickers)
ticker = Exchange.get_ticker_by_instrument("BTC_USDT")
print(ticker)
API
Client
Client.init(api_key, chain_id, provider=None): Initialize the SDK with API key, chain, and optional provider.
Wallet
Wallet.create(): Creates a new wallet.Wallet.get_balance(address): Returns the native token balance for a given wallet address.
Token
Token.get_native_balance(address): Fetches native token balance.Token.get_erc20_balance(address, contract_address, block_height='latest'): Fetches ERC20 token balance.Token.transfer_token(to, amount): Transfers tokens.Token.wrap_token(from_contract_address, to_contract_address, to, amount): Wraps tokens.Token.swap_token(from_contract_address, to_contract_address, to, amount): Swaps tokens.
Transaction
Transaction.get_transaction_by_hash(tx_hash): Returns a transaction by hash.Transaction.get_transaction_status(tx_hash): Returns the status of a transaction.Transaction.get_transaction_count(address): Returns nonce for a wallet.Transaction.get_gas_price(): Returns current gas price.Transaction.get_fee_data(): Returns fee-related data.Transaction.estimate_gas(payload): Estimates gas for a given transaction payload.
Contract
Contract.get_contract_code(contract_address): Fetches contract bytecode.
Block
Block.get_current_block(): Returns the latest block.Block.get_by_tag(tag, tx_detail=False): Returns a block by tag or number.
CronosId
CronosId.forward_resolve(cronos_id): Resolves CronosId to address.CronosId.reverse_resolve(address): Resolves address to CronosId.
DeFi
Defi.get_whitelisted_tokens(protocol): Returns list of whitelisted tokens.Defi.get_all_farms(protocol): Returns all farms.Defi.get_farm_by_symbol(protocol, symbol): Returns specific farm by symbol.
Exchange
Exchange.get_all_tickers(): Returns all tickers.Exchange.get_ticker_by_instrument(instrument_name): Returns specific ticker info.
Supported Chains
The SDK supports both Cronos EVM and Cronos ZK EVM networks.
from crypto_com_developer_platform_client.interfaces.chain_interfaces import CronosEvm, CronosZkEvm
CronosEvm.MAINNET # Chain ID: 25
CronosEvm.TESTNET # Chain ID: 338
CronosZkEvm.MAINNET # Chain ID: 388
CronosZkEvm.TESTNET # Chain ID: 240
License
This project is licensed under the MIT License.
Contact
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crypto_com_developer_platform_client-1.1.1-py3-none-any.whl.
File metadata
- Download URL: crypto_com_developer_platform_client-1.1.1-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eed400fdaa917086890c9dc0199d263de4a6d1500a614a6b9372a55540419853
|
|
| MD5 |
d7acced06030b15739f922e3cf93d695
|
|
| BLAKE2b-256 |
67b1edd2f7222b3c2d03c83a33ead589d70b962fe071092ea7afcd1180d4b0a3
|