{"id":25244212,"url":"https://github.com/exploring-solver/iitkcyberhack","last_synced_at":"2025-06-15T01:39:59.606Z","repository":{"id":278896812,"uuid":"921924769","full_name":"exploring-solver/iitkcyberhack","owner":"exploring-solver","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-22T11:05:29.000Z","size":4033,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T12:18:54.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exploring-solver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-24T22:02:32.000Z","updated_at":"2025-02-22T11:05:32.000Z","dependencies_parsed_at":"2025-02-22T12:29:27.410Z","dependency_job_id":null,"html_url":"https://github.com/exploring-solver/iitkcyberhack","commit_stats":null,"previous_names":["exploring-solver/iitkcyberhack"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exploring-solver%2Fiitkcyberhack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exploring-solver%2Fiitkcyberhack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exploring-solver%2Fiitkcyberhack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exploring-solver%2Fiitkcyberhack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exploring-solver","download_url":"https://codeload.github.com/exploring-solver/iitkcyberhack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399887,"owners_count":20932876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-12T01:18:07.423Z","updated_at":"2025-04-05T20:44:35.634Z","avatar_url":"https://github.com/exploring-solver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cross-Chain Asset Transfer System\n\n\n## Overview\nThis project implements a **Cross-Chain Asset Transfer System** where assets can be locked on one blockchain and minted as a representation on another. The system consists of smart contracts deployed on two test networks (**LocalAmoy** and **LocalSepolia**) that enable the secure transfer of ERC20 tokens and NFTs between chains.\n\nThe system ensures:\n- **Security**: Assets are locked before being minted on the other chain.\n- **Transparency**: Users can verify all transactions on the blockchain.\n- **Proof-of-Transfer**: The transfer process is traceable on both chains.\n\n## Project Setup and Installation\n\n### Prerequisites\n- **Node.js** (\u003e=16.x)\n- **Hardhat** (Ethereum development framework)\n- **Metamask** (for interacting with test networks)\n- **Ganache** (optional for local blockchain simulation)\n\n### Installation\n```sh\n# Clone the repository\ngit clone https://github.com/exploring-solver/iitkcyberhack.git\ncd cross-chain-transfer\n\n# Install dependencies\nnpm install\n```\n\n### Hardhat Local Blockchain Setup\nRun two separate local blockchain nodes on different ports:\n```sh\nnpx hardhat node --port 8545 # LocalAmoy\nnpx hardhat node --port 8546 # LocalSepolia\n```\n\n## Deploy Smart Contracts\n### Deploy on LocalAmoy\n```sh\nnpx hardhat run scripts/deployAmoy.js --network localAmoy\n```\n### Deploy on LocalSepolia\n```sh\nnpx hardhat run scripts/deploySepolia.js --network localSepolia\n```\n\n## ERC20 Token Transfer Steps\n### Step 1: Lock Tokens on LocalAmoy\n```sh\nnpx hardhat console --network localAmoy\n```\n```js\nconst token = await ethers.getContractAt(\"ERC20\", \"\u003clocalAmoy token address\u003e\");\nconst bridge = await ethers.getContractAt(\"BridgeAmoy\", \"\u003clocalAmoy bridge address\u003e\");\nawait token.approve(bridge.target, ethers.parseEther(\"10\"));  \nawait bridge.lock(ethers.parseEther(\"10\"));\nconst balance = await token.balanceOf(\"\u003cyour_address\u003e\");\nconsole.log(`Sender's balance on LocalAmoy: ${ethers.formatEther(balance)}`);\n```\n\n### Step 2: Release Tokens on LocalSepolia\n```sh\nnpx hardhat console --network localSepolia\n```\n```js\nconst bridge = await ethers.getContractAt(\"BridgeSepolia\", \"\u003clocalSepolia bridge address\u003e\");\nawait bridge.release(\"\u003cyour_address\u003e\", ethers.parseEther(\"10\"));\nconst token = await ethers.getContractAt(\"ERC20\", \"\u003clocalSepolia token address\u003e\");\nconst balance = await token.balanceOf(\"\u003cyour_address\u003e\");\nconsole.log(`Receiver's balance on LocalSepolia: ${ethers.formatEther(balance)}`);\n```\n\n### Step 3: Burn Tokens on LocalSepolia\n```sh\nnpx hardhat console --network localSepolia\n```\n```js\nawait token.approve(bridge.target, ethers.parseEther(\"10\"));\nawait bridge.burn(ethers.parseEther(\"10\"));\nconst balance = await token.balanceOf(\"\u003cyour_address\u003e\");\nconsole.log(`Sender's balance on LocalSepolia: ${ethers.formatEther(balance)}`);\n```\n\n### Step 4: Unlock Tokens on LocalAmoy\n```sh\nnpx hardhat console --network localAmoy\n```\n```js\nawait bridge.unlock(\"\u003cyour_address\u003e\", ethers.parseEther(\"10\"));\nconst balance = await token.balanceOf(\"\u003cyour_address\u003e\");\nconsole.log(`Receiver's balance on LocalAmoy: ${ethers.formatEther(balance)}`);\n```\n\n## NFT Transfer Steps\n### Step 1: Deploy NFT Contracts\n#### Deploy on LocalAmoy\n```sh\nnpx hardhat run scripts/deployAmoyNFT.js --network localAmoy\n```\n#### Deploy on LocalSepolia\n```sh\nnpx hardhat run scripts/deploySepoliaNFT.js --network localSepolia\n```\n\n### Step 2: Mint and Lock NFT on LocalAmoy\n```sh\nnpx hardhat console --network localAmoy\n```\n```js\nconst nft = await ethers.getContractAt(\"NativeNFT\", \"\u003clocalAmoy NFT address\u003e\");\nconst bridge = await ethers.getContractAt(\"BridgeAmoyNFT\", \"\u003clocalAmoy bridge address\u003e\");\nconst [signer] = await ethers.getSigners();\nconst userAddress = await signer.getAddress();\nawait bridge.mint(userAddress); // Mint NFT with ID 1\nconst tokenId = 1;\nawait nft.approve(bridge.target, tokenId);\nawait bridge.lock(tokenId);\nconst owner = await nft.ownerOf(tokenId);\nconsole.log(`NFT ${tokenId} owner on LocalAmoy: ${owner}`);\n```\n\n### Step 3: Release Wrapped NFT on LocalSepolia\n```sh\nnpx hardhat console --network localSepolia\n```\n```js\nconst bridge = await ethers.getContractAt(\"BridgeSepoliaNFT\", \"\u003clocalSepolia bridge address\u003e\");\nawait bridge.release(userAddress, tokenId);\nconst wrappedNFT = await ethers.getContractAt(\"WrappedNFT\", \"\u003clocalSepolia Wrapped NFT address\u003e\");\nconst newOwner = await wrappedNFT.ownerOf(tokenId);\nconsole.log(`Wrapped NFT ${tokenId} owner on LocalSepolia: ${newOwner}`);\n```\n\n## Explanation of Key Concepts\n### Lock and Release Mechanism\n1. **Locking**: When an asset is locked on one blockchain, it gets temporarily held by the bridge contract, preventing double spending.\n2. **Minting**: A representation of the locked asset is created on the destination blockchain.\n3. **Burning \u0026 Unlocking**: When the asset is burned on the second blockchain, the original asset is unlocked on the first blockchain.\n\n### Wrapped NFT Concept\n- The **WrappedNFT** is a copy of the original NFT that represents ownership on another chain.\n- When the original NFT is locked, a wrapped version is minted on the second chain.\n- When the wrapped NFT is burned, the original NFT is released back to its owner.\n\n## Conclusion\nThis project successfully demonstrates a **cross-chain asset transfer system** using smart contracts on **LocalAmoy** and **LocalSepolia** networks. It ensures **security, transparency, and traceability** in asset transfers.\n\n## Future Enhancements\n- **Automated relayers** to validate cross-chain transactions without manual intervention.\n- **Integration with mainnet blockchains** such as Ethereum, Polygon, or Binance Smart Chain.\n- **Support for additional asset types** beyond ERC20 tokens and NFTs.\n\n## License\nThis project is licensed under the MIT License.\n\n\n\n# Gasless Token Transfer with EIP-2612 Permit\n\nThis project demonstrates gasless token transfers using EIP-2612 permit functionality. The sender signs a permit message, and the recipient executes the transfer, paying for the gas fees.\n\n## Prerequisites\n\n- Node.js and npm installed\n- MetaMask browser extension\n- Basic understanding of Ethereum and smart contracts\n\n## Setup Instructions\n\n### 1. Local Blockchain Setup\n\n```bash\n# Install Ganache globally\nnpm install -g ganache\n\n# Start Ganache\nganache\n```\n\n- Copy the first two private keys displayed in the Ganache CLI output\n\n### 2. MetaMask Setup\n\n1. Add Local Network to MetaMask:\n   - Network Name: Localhost 8545\n   - New RPC URL: http://127.0.0.1:8545\n   - Chain ID: 1337\n   - Currency Symbol: ETH\n\n2. Import Accounts:\n   - Click on \"Import Account\" in MetaMask\n   - Paste the first private key from Ganache\n   - Repeat for the second private key\n\n### 3. Project Setup\n\n```bash\n# Install dependencies\nnpm install\n\n# Deploy contracts\ntruffle migrate --reset --network development\n\n# Copy contract artifacts\n# Copy the following files from build/contracts to frontend/src/contracts:\n# - Forwarder.json\n# - TestToken.json\n```\n\nImportant: Note down the deployed contract addresses for:\n- TestToken contract\n- Forwarder contract\n\n### 4. Frontend Setup\n\n```bash\n# Navigate to frontend directory\ncd frontend\n\n# Install dependencies\nnpm install\n\n# Start development server\nnpm run dev\n```\n\n### 5. Using the Application\n\n1. Connect Accounts:\n   - Connect both MetaMask accounts to the frontend\n   - First account will be the sender\n   - Second account will be the recipient\n\n2. Token Transfer Process:\n   - From sender account:\n     - Enter recipient address\n     - Enter amount of TEST tokens\n     - Sign the permit\n   - Switch to recipient account:\n     - Execute the transfer\n     - Confirm the transaction (recipient pays gas)\n\n## Contract Addresses\n\nAfter deployment, update the following addresses in your frontend configuration:\n\n- TestToken: `\u003cYOUR_TEST_TOKEN_ADDRESS\u003e`\n- Forwarder: `\u003cYOUR_FORWARDER_ADDRESS\u003e`\n\n## Testing\n\n```bash\n# Run tests\ntruffle test\n```\n\n## Security Considerations\n\n- Always verify the permit data before signing\n- Check token allowances and balances\n- Verify contract addresses\n- Never share private keys\n\n## Troubleshooting\n\n1. **MetaMask Connection Issues**:\n   - Ensure you're connected to the correct network\n   - Reset MetaMask account if transactions are stuck\n\n2. **Transaction Failures**:\n   - Check gas limits\n   - Verify token balances\n   - Ensure permit hasn't expired\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexploring-solver%2Fiitkcyberhack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexploring-solver%2Fiitkcyberhack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexploring-solver%2Fiitkcyberhack/lists"}