Skip to main content

The simplest Python SDK for Chainlink CCIP that turns complex cross-chain operations into 15 lines of code.

Project description

CCIP SDK

A simple Python SDK for Chainlink CCIP (Cross-Chain Interoperability Protocol) that enables seamless cross-chain token transfers and messaging.

Features

  • 🚀 Deploy sender and receiver contracts across multiple testnets
  • 💰 Send tokens and ETH to contracts
  • 🔗 Configure cross-chain permissions
  • ⚡ Execute cross-chain transfers with built-in monitoring
  • 📊 Transaction tracking and URL generation

Installation

pip install ccip-sdk

Quick Start

1. Environment Setup

Create a .env file in your project root:

PRIVATE_KEY=your_private_key_here

2. Basic Usage

from ccip_sdk import CCIPClient
from dotenv import load_dotenv
import os

load_dotenv()

# Initialize client
client = CCIPClient(private_key=os.environ.get("PRIVATE_KEY"))

# Deploy contracts and perform cross-chain transfer
contract = client.deploy_sender_contract("ethereum_sepolia")
print(f"Deployed contract address: {contract}")

# Fund the contract
txn_hash = client.send_tokens_to_sender_contract("ethereum_sepolia", "CCIP-BnM", 0.1)
print(f"Tokens sent: {txn_hash}")

# Transfer across chains
txn_url = client.transfer(
    sender_chain="ethereum_sepolia", 
    receiver_chain="arbitrum_sepolia", 
    text="Hello Cross-Chain!", 
    amount=0.069
)
print(f"Track transfer: {txn_url}")

Complete Example

from ccip_sdk import CCIPClient
from dotenv import load_dotenv
import os

load_dotenv()

client = CCIPClient(private_key=os.environ.get("PRIVATE_KEY"))

# Step 1: Deploy sender contract on Ethereum Sepolia
contract = client.deploy_sender_contract("ethereum_sepolia")
print(f"Deployed contract address: {contract}\n")

# Step 2: Fund sender contract with tokens
txn_hash = client.send_tokens_to_sender_contract("ethereum_sepolia", "CCIP-BnM", 0.1)
print(f"Token sent via this transaction hash : {txn_hash}\n")

# Step 3: Fund sender contract with ETH (for gas fees)
txn_hash = client.send_eth_to_contract("ethereum_sepolia", 0.05)
print(f"ETH sent via this transaction hash : {txn_hash}\n")

# Step 4: Allow destination chain for cross-chain messaging
txn_hash = client.allow_destination_chain(current_chain="ethereum_sepolia", destination_chain="arbitrum_sepolia")
print(f"Allowed destination chain arbitrum_sepolia done with txnHash : {txn_hash}\n")

# Step 5: Deploy receiver contract on Arbitrum Sepolia
contract = client.deploy_receiver_contract("arbitrum_sepolia")
print(f"Deployed contract address: {contract}\n")

# Step 6: Allow source chain on receiver
txn_hash = client.allow_source_chain(current_chain="arbitrum_sepolia", sender_chain="ethereum_sepolia")
print(f"Allowed sender chain ethereum_sepolia done with txnHash : {txn_hash}\n")

# Step 7: Allow sender contract to send messages to receiver
txn_hash = client.allow_sender_on_receiver(sender_chain="ethereum_sepolia", receiver_chain="arbitrum_sepolia")
print(f"Allowed the sender contract to send messages on reciever chain with txnHash : {txn_hash}\n")

# Step 8: Execute cross-chain transfer
txn_url = client.transfer(sender_chain="ethereum_sepolia", receiver_chain="arbitrum_sepolia", text="Hi dj boi", amount=0.069)
print(f"You can watch the CCIP Transfer here : {txn_url}\n")

Step-by-Step Explanation

1. Contract Deployment

  • deploy_sender_contract(): Deploys a contract that can send cross-chain messages
  • deploy_receiver_contract(): Deploys a contract that can receive cross-chain messages

2. Contract Funding

  • send_tokens_to_sender_contract(): Funds the sender with tokens for transfer
  • send_eth_to_contract(): Funds the sender with ETH for transaction fees

3. Permission Setup

  • allow_destination_chain(): Authorizes the sender to communicate with a specific destination chain
  • allow_source_chain(): Authorizes the receiver to accept messages from a specific source chain
  • allow_sender_on_receiver(): Links sender and receiver contracts for communication

4. Cross-Chain Transfer

  • transfer(): Executes the cross-chain token transfer with optional message

Supported Networks

Chain Name Network Purpose
ethereum_sepolia Ethereum Sepolia Testnet Primary testing network
arbitrum_sepolia Arbitrum Sepolia Testnet L2 scaling solution
base_sepolia Base Sepolia Testnet Coinbase L2 network
avalanche_fuji Avalanche Fuji Testnet High-performance blockchain

Supported Tokens

Token Description Use Case
LINK Chainlink Token Network fees and staking
CCIP-BnM Burn and Mint Token Cross-chain transfers
USDC USD Coin Stable value transfers
CCIP-LnM Lock and Mint Token Alternative transfer mechanism

Requirements

  • Python 3.7+
  • Valid private key with testnet funds
  • Access to supported testnet RPCs

Security Note

⚠️ Never commit your private key to version control. Always use environment variables or secure key management solutions.

Contributing

We welcome contributions! Here's how you can help:

Getting Started

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Development Setup

git clone https://github.com/your-username/ccip_sdk.git
cd ccip_sdk
pip install -e .
pip install -r requirements-dev.txt

Running Tests

pytest tests/

Code Style

  • Follow PEP 8 guidelines
  • Use type hints where applicable
  • Add docstrings for public methods
  • Ensure 80% test coverage

Issues and Feature Requests

  • Check existing issues before creating new ones
  • Provide detailed descriptions and reproduction steps
  • Tag issues appropriately (bug, enhancement, documentation)

Documentation

  • Update README.md for new features
  • Add inline code documentation
  • Provide usage examples

License

MIT License - see LICENSE for details.

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccip_sdk-0.1.11.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ccip_sdk-0.1.11-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file ccip_sdk-0.1.11.tar.gz.

File metadata

  • Download URL: ccip_sdk-0.1.11.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ccip_sdk-0.1.11.tar.gz
Algorithm Hash digest
SHA256 7e4a0e3def5956e8e61a06fbf5049d1825fef50376d4b49b3f78d7b26fa28bc5
MD5 ae5d0b3af54f5f18cf96b1d921da9449
BLAKE2b-256 a02a93f889b76213ffeef830e4dcb3268052e1072627e0e2633bdc334bae9162

See more details on using hashes here.

File details

Details for the file ccip_sdk-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: ccip_sdk-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ccip_sdk-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e57c070a2e8b6e60c9a024278d1cb3f8fb311256ab325d0d249d020850e08ff5
MD5 7de1ca252a207d80b62cab734f1bdb37
BLAKE2b-256 ca3f15934068506a7918bdb509d969782bfda06e11ddd8eb3205e36b0ba3f4a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page