Source Chain Smart Contracts
An overview of source chain smart contracts and the best practice pattern to securely query their data on Creditcoin using the Creditcoin oracle.
What is a Source Chain Smart Contract?
Source chain logic
Emitting Events
Example Source chain contract
// 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
Last updated

