# Source Chain Smart Contracts

{% hint style="danger" %}
**Outdated Documentation:** This page covers the architecture used for USC V1, which was deprecated on 2026-03-30. For the latest documentation, please visit: [usc documentation](https://docs.creditcoin.org/usc)
{% endhint %}

## What is a Source Chain Smart Contract?

A source chain smart contract is a contract living on a chain such as <img src="/files/7JS1nXRkaVNdby4MMITR" alt="" data-size="line"> `Ethereum` that is supported by the <img src="/files/ZABpsfb0M5qJd9lXhaEc" alt="" data-size="line"> `Creditcoin` Oracle. Source chain contracts have two main responsibilities:

1. Support any source chain logic required by the Universal DApp.
2. Emit events which can be converted into Creditcoin oracle queries.

Let's focus on these one by one.

### Source chain logic

Most logic and data for Universal DApps should live in a DApp contract on the *execution chain* rather than the *source chain.* But some minimal logic such as moving assets may need still to occur on the source chain. Try and keep this as small possible, since what makes Creditcoin DApps universal is the fact that most of their business logic is encompassed on the Creditcoin execution chain.

### Emitting Events

This is the way by which your *source chain* will communicate with the *execution chain*. Imagine that you want a simple DApp which burns `ERC20` tokens on Ethereum and mints corresponding `ERC20` tokens on Creditcoin. Then you would want your [source chain smart contract](https://app.gitbook.com/o/-LjFKFsSaSJudznvwK-5/s/Vp3bVdljVxZuwysnIzZ1/~/edit/~/changes/108/usc-v1/dapp-builder-infrastructure/infrastructure-overview#source-chain-smart-contract) to emit an event such as `TokensBurnedForBridging`.

### Example Source chain contract

The following is a simple source chain smart contract. The Universal DApp it supports is a cross chain token bridge which burns `ERC20` tokens on a source chain such as Sepolia and mints corresponding tokens in a Universal DApp contract on Creditcoin.

The most important part of this contract is the `TokensBurnedForBridging` event which emitted in the `burn()` function. This event is picked up by an [offchain worker](/usc/dapp-builder-infrastructure/offchain-oracle-workers.md) and eventually triggers token minting on Creditcoin.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract TestERC20 is ERC20 {
    address public constant BURN_ADDRESS = address(1); // 0x...01
    
  /// This event is bridged by the Creditcoin Oracle to trigger token minting
  /// @notice Emitted when tokens are burned (sent to the burn address).
  /// @param from The address burning their tokens
  /// @param value The amount of tokens burned
  event TokensBurnedForBridging(address indexed from, uint256 indexed value);
  
  constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {
      _mint(msg.sender, 1_000_000 ether);
  }
  
  /// The `TokensBurnedForBridging` event emitted by this call is bridged via the 
  /// Creditcoin Oracle to mint tokens on Creditcoin
  /// @notice "Burn" by transferring tokens to the 0x...01 sink address. 
  function burn(uint256 amount) external returns (bool) {
      _transfer(msg.sender, BURN_ADDRESS, amount);
      emit TokensBurnedForBridging(msg.sender, amount);
      return true;
  }
}
```

## Next Steps

[Universal Smart Contracts](/usc/dapp-builder-infrastructure/universal-smart-contracts.md)

*Check out* [*this tutorial*](https://github.com/gluwa/ccnext-testnet-bridge-examples) *for an example of how to use the Creditcoin stack to set up a decentralized trustless bridge.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.creditcoin.org/usc/usc-v1/dapp-builder-infrastructure/source-chain-smart-contracts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
