# CCIP Sender Contract Reference

**Contract Address**: `0x105F8A15b819948a89153505762444Ee9f324684`  
**Network**: ChainID 138  
**RPC Endpoint**: `http://192.168.11.250:8545` or `https://rpc-core.d-bis.org`  
**Block Explorer**: `https://explorer.d-bis.org` (Blockscout)  
**Contract Type**: CCIP Sender (Cross-Chain Interoperability Protocol)

---

## 📋 Contract Overview

The CCIP Sender contract is part of the Chainlink CCIP (Cross-Chain Interoperability Protocol) infrastructure deployed on Chain 138. It handles the initiation and submission of cross-chain messages.

### Purpose
- Initiates CCIP messages for cross-chain communication
- Handles message preparation and submission to the CCIP Router
- Manages cross-chain message flow from Chain 138 to destination chains

### ⚠️ Important: Dual Role Across Chains

**On Chain 138 (Source Chain)**:
- **Role**: CCIP Sender contract
- **Function**: Initiates cross-chain transfers FROM Chain 138

**On Destination Chains** (BSC, Avalanche, Base, Arbitrum, Optimism):
- **Role**: CCIPWETH10Bridge contract  
- **Function**: Receives and processes WETH10 tokens FROM Chain 138
- **Address**: Same address (`0x105f8a15b819948a89153505762444ee9f324684`)

This is why this address appears in CCIP transfers - it's the **destination bridge contract** that receives tokens when bridging WETH10 from Chain 138 to other chains.

---

## 🔗 Related Contracts

### CCIP Router
- **Address**: `0x8078A09637e47Fa5Ed34F626046Ea2094a5CDE5e`
- **Relationship**: The CCIP Sender interacts with the CCIP Router to send messages
- **Fee Token**: `0x514910771AF9Ca656af840dff83E8264EcF986CA` (LINK)
- **Base Fee**: 1000000000000000 wei
- **Data Fee Per Byte**: 100000000 wei

### Bridge Contracts
- **CCIPWETH9Bridge**: `0x89dd12025bfCD38A168455A44B400e913ED33BE2`
- **CCIPWETH10Bridge**: `0xe0E93247376aa097dB308B92e6Ba36bA015535D0`

---

## 📊 Contract Status

| Property | Value |
|----------|-------|
| **Status** | ✅ Deployed |
| **Chain ID** | 138 |
| **Deployment Block** | (Check Blockscout) |
| **Verified** | ⏳ Pending verification on Blockscout |
| **Bytecode** | Available (confirmed via RPC) |

### ⚠️ Important: Ethereum Mainnet Address is NOT Functional

**On Ethereum Mainnet**: The address `0x105F8A15b819948a89153505762444Ee9f324684` has **empty bytecode** (`0x`), meaning:
- ❌ **No contract exists** at this address on mainnet
- ❌ **Not functional** - cannot be used for any operations
- ❌ **Not relevant** for this project - ignore mainnet address entirely

**On Chain 138**: The same address has **deployed contract bytecode** (~5KB), meaning:
- ✅ The CCIP Sender contract is actively deployed and operational
- ✅ This is the **only relevant address** for this project
- ✅ Use this address for all Chain 138 operations

**Why mention mainnet?**
- The address appears on Etherscan because addresses can exist across all chains
- **However, it has no functionality on mainnet** - it's just an empty address
- **Focus on Chain 138 only** - that's where the contract is actually deployed and used

---

## 🔧 Configuration

### For CCIP Monitor Service (VMID 3501)

The CCIP Sender contract is used by the CCIP Monitor service. Configuration in `/opt/ccip-monitor/.env`:

```bash
CCIP_ROUTER_ADDRESS=0x8078A09637e47Fa5Ed34F626046Ea2094a5CDE5e
CCIP_SENDER_ADDRESS=0x105F8A15b819948a89153505762444Ee9f324684
RPC_URL=http://192.168.11.250:8545
CHAIN_ID=138
LINK_TOKEN_ADDRESS=0x514910771AF9Ca656af840dff83E8264EcF986CA
METRICS_PORT=8000
CHECK_INTERVAL=60
```

---

## 🔍 Contract Verification

### Verify on Blockscout

To verify this contract on Blockscout (the explorer for Chain 138):

```bash
cd /home/intlc/projects/smom-dbis-138

# Verify using Foundry
forge verify-contract \
  0x105F8A15b819948a89153505762444Ee9f324684 \
  src/CCIPSender.sol:CCIPSender \
  --chain-id 138 \
  --verifier blockscout \
  --verifier-url https://explorer.d-bis.org/api \
  --rpc-url http://192.168.11.250:8545
```

### Contract Source Location

The source code should be in:
- `/home/intlc/projects/smom-dbis-138/src/CCIPSender.sol`
- Deployment script: `/home/intlc/projects/smom-dbis-138/script/DeployCCIPSender.s.sol`

---

## 📡 Querying the Contract

### Using Cast (Foundry)

```bash
# Get contract bytecode
cast code 0x105F8A15b819948a89153505762444Ee9f324684 \
  --rpc-url http://192.168.11.250:8545

# Get contract storage (slot 0)
cast storage 0x105F8A15b819948a89153505762444Ee9f324684 0 \
  --rpc-url http://192.168.11.250:8545

# Call a function (example - adjust based on actual ABI)
cast call 0x105F8A15b819948a89153505762444Ee9f324684 \
  "router()(address)" \
  --rpc-url http://192.168.11.250:8545
```

### Using Web3/ethers.js

```javascript
const { ethers } = require("ethers");

const provider = new ethers.providers.JsonRpcProvider("http://192.168.11.250:8545");
const contractAddress = "0x105F8A15b819948a89153505762444Ee9f324684";

// Example ABI (adjust based on actual contract)
const abi = [
  "function router() view returns (address)",
  "function sendMessage(uint64 destinationChainSelector, bytes data) payable returns (bytes32)"
];

const contract = new ethers.Contract(contractAddress, abi, provider);

// Call contract functions
const router = await contract.router();
console.log("CCIP Router:", router);
```

---

## 🌐 Cross-Chain Integration

### Supported Destination Chains

The CCIP Sender can send messages to the following chains:

| Chain | Chain ID | Chain Selector | Status |
|-------|----------|----------------|--------|
| **BSC** | 56 | 11344663589394136015 | ✅ Configured |
| **Polygon** | 137 | 4051577828743386545 | ✅ Configured |
| **Avalanche** | 43114 | 6433500567565415381 | ✅ Configured |
| **Base** | 8453 | 15971525489660198786 | ✅ Configured |
| **Arbitrum** | 42161 | (Check deployment) | ⏳ Pending |
| **Optimism** | 10 | (Check deployment) | ⏳ Pending |

### Sending Cross-Chain Messages

```solidity
// Example: Send a message to BSC
uint64 destinationChainSelector = 11344663589394136015; // BSC
bytes memory data = abi.encode(/* your data */);

// Approve LINK tokens for fees (if using LINK)
IERC20 linkToken = IERC20(0x514910771AF9Ca656af840dff83E8264EcF986CA);
linkToken.approve(routerAddress, feeAmount);

// Send message
bytes32 messageId = ccipSender.sendMessage(
    destinationChainSelector,
    data
);
```

---

## 📝 Events

The CCIP Sender contract emits events for monitoring. Key events include:

### MessageSent Event
```solidity
event MessageSent(
    bytes32 indexed messageId,
    uint64 indexed sourceChainSelector,
    address sender,
    bytes data,
    address[] tokenAmounts,
    address feeToken,
    bytes extraArgs
);
```

### Monitoring with CCIP Monitor Service

The CCIP Monitor service (VMID 3501) listens to these events and tracks:
- Message latency
- Message fees
- Success/failure rates
- Cross-chain message flow

---

## 🔐 Security Considerations

1. **Access Control**: Only authorized addresses can send messages
2. **Fee Management**: Ensure sufficient LINK tokens for fees
3. **Destination Validation**: Verify destination chain selectors are correct
4. **Message Validation**: Validate message data before sending

---

## 📚 Related Documentation

- [Contract Addresses Reference](/docs/11-references/CONTRACT_ADDRESSES_REFERENCE.md)
- [Final Contract Addresses](./FINAL_CONTRACT_ADDRESSES.md)
- [Cross-Chain Bridge Addresses](./CROSS_CHAIN_BRIDGE_ADDRESSES.md)
- [Deployed Contracts Final](./DEPLOYED_CONTRACTS_FINAL.md)
- [Complete Connections, Contracts, and Containers](./COMPLETE_CONNECTIONS_CONTRACTS_CONTAINERS.md)

---

## 🔗 External Links

- **Blockscout (Chain 138)**: `https://explorer.d-bis.org/address/0x105F8A15b819948a89153505762444Ee9f324684` ✅ **Use this**
- **Chainlink CCIP Documentation**: https://docs.chain.link/ccip
- **Source Project**: `/home/intlc/projects/smom-dbis-138`

### ⚠️ Network-Specific Usage

**This contract is ONLY functional on Chain 138:**

- **Chain 138**: `0x105F8A15b819948a89153505762444Ee9f324684` ✅ **Deployed and operational**
- **Ethereum Mainnet**: `0x105F8A15b819948a89153505762444Ee9f324684` ❌ **Not functional - ignore**

**Note**: While the address exists on mainnet (with empty bytecode), it has no functionality there and is not relevant for this project. Only use this address on Chain 138.

---

## 📋 Quick Reference

```bash
# Contract Address
CCIP_SENDER=0x105F8A15b819948a89153505762444Ee9f324684

# Related Contracts
CCIP_ROUTER=0x8078A09637e47Fa5Ed34F626046Ea2094a5CDE5e
LINK_TOKEN=0x514910771AF9Ca656af840dff83E8264EcF986CA

# RPC Endpoint
RPC_URL=http://192.168.11.250:8545
# or
RPC_URL=https://rpc-core.d-bis.org

# Block Explorer
EXPLORER_URL=https://explorer.d-bis.org/address/0x105F8A15b819948a89153505762444Ee9f324684
```

---

**Last Updated**: $(date)  
**Status**: ✅ Contract deployed and operational on Chain 138

