Cross-chain Bridges Basics
📖 Scenario: You are building a simple program to track token transfers between two blockchains using a cross-chain bridge. This helps users move tokens safely from one chain to another.
🎯 Goal: Create a program that stores token balances on two chains, sets a minimum transfer amount, processes transfers only if they meet the minimum, and shows the updated balances.
📋 What You'll Learn
Create a dictionary called
chain_balances with exact keys 'ChainA' and 'ChainB' and initial balances 1000 and 500 respectivelyCreate a variable called
min_transfer and set it to 100Write a function called
transfer_tokens that takes amount and transfers tokens from 'ChainA' to 'ChainB' only if amount is greater than or equal to min_transferPrint the updated
chain_balances after a transfer of 150 tokens💡 Why This Matters
🌍 Real World
Cross-chain bridges let users move tokens between different blockchains, enabling more flexible and powerful blockchain applications.
💼 Career
Understanding how to track and control token transfers across chains is important for blockchain developers working on decentralized finance (DeFi) and interoperability solutions.
Progress0 / 4 steps