{"id":19517257,"url":"https://github.com/puneethkumarck/crypto-api","last_synced_at":"2025-04-15T21:26:36.612Z","repository":{"id":256543763,"uuid":"855697096","full_name":"Puneethkumarck/crypto-api","owner":"Puneethkumarck","description":"Apis to interact with crypto blockchains Solana , Ethereum etc","archived":false,"fork":false,"pushed_at":"2025-03-03T17:32:27.000Z","size":1186,"stargazers_count":1,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T01:34:19.199Z","etag":null,"topics":["blockchain","ethereum","grpc","hexagonal-architecture","java21","solana","transactions","web3j","wiremock"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Puneethkumarck.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":"2024-09-11T10:07:12.000Z","updated_at":"2025-01-05T14:02:24.000Z","dependencies_parsed_at":"2024-11-09T13:31:34.968Z","dependency_job_id":"cd24778b-aff9-4ab3-a20c-48f4fa22270b","html_url":"https://github.com/Puneethkumarck/crypto-api","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":"0.11111111111111116","last_synced_commit":"a71128a0fd92d1db63493632aef4d8cd1f16e1b9"},"previous_names":["puneethkumarck/crypto-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fcrypto-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fcrypto-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fcrypto-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fcrypto-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Puneethkumarck","download_url":"https://codeload.github.com/Puneethkumarck/crypto-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249156006,"owners_count":21221697,"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":["blockchain","ethereum","grpc","hexagonal-architecture","java21","solana","transactions","web3j","wiremock"],"created_at":"2024-11-11T00:01:19.838Z","updated_at":"2025-04-15T21:26:36.592Z","avatar_url":"https://github.com/Puneethkumarck.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Puneethkumarck_crypto-api\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Puneethkumarck_crypto-api)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Puneethkumarck_crypto-api\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=Puneethkumarck_crypto-api)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Puneethkumarck_crypto-api\u0026metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=Puneethkumarck_crypto-api)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Puneethkumarck_crypto-api\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Puneethkumarck_crypto-api)\n\n[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/aYpw1-?referralCode=F4Yi_e)\n# Crypto API\n\nThe Crypto API provides seamless interaction with the Solana blockchain, allowing users to check balances, transfer SOL tokens, and handle airdrops in the event of insufficient funds.\n\n## Table of Contents\n- [Key Features](#key-features)\n- [Technologies Used](#technologies-used)\n- [Transfer SOL Flow](#transfer-sol-flow)\n  - [Components](#components)\n  - [System Diagram](#system-diagram)\n  - [Sequence Diagram](#sequence-diagram)\n- [Transfer Ethereum Flow](#transfer-ethereum-flow)\n  - [Components](#components)\n  - [System Diagram](#system-diagram)\n  - [Sequence Diagram](#sequence-diagram)\n- [Running the Application](#running-the-application)\n- [Testing the API](#testing-the-api)\n  - [Get Balance](#1-get-balance)\n  - [Transfer SOL](#2-transfer-sol)\n  - [Transfer Ethereum](#3-transfer-ethereum)\n- [Blockchain Transaction Details](#blockchain-transaction-details)\n- [Deployed Application](#deployed-application)\n\n\n## Key Features\n- **Check Balance**: Retrieve the SOL balance for any Solana wallet.\n- **Transfer SOL**: Transfer SOL between two wallets with automatic validation and SOL airdrop for insufficient funds.\n  - Both sender and receiver balances are checked.\n  - If funds are insufficient, an airdrop is automatically initiated to complete the transaction.\n\n## Technologies Used\n- **Java 21**: Leveraging the latest features for performance and scalability.\n- **Spring Boot 3.3.3**: Simplifies building production-ready applications.\n- **Hexagonal Architecture**: Clean separation between core logic and infrastructure for better maintainability.\n- **WireMock**: For mocking API interactions during tests.\n- **SpringDoc OpenAPI**: Auto-generates OpenAPI documentation for improved API interoperability.\n- **GitHub Actions**: CI/CD pipelines for automated testing and quality analysis.\n- **SonarCloud**: Ensures code quality and security with continuous static analysis.\n- **Codacy**: Provides additional insights into code quality.\n\n## Transfer SOL Flow\n\n### Components\n![component_diagram.png](docs/component_diagram.png)\n\n### System Diagram\nThe diagram below illustrates the interaction between components within the hexagonal architecture for SOL transfers.\n\n![hexagonal.png](docs/hexagonal.png)\n\n### Sequence Diagram\nThis diagram details the sequence of operations that occur during a SOL transfer.\n\n![sequencediagram.png](docs/sequence_diagram.png)\n\n## Transfer Ethereum Flow\n\n### Components\nThe Ethereum transfer system uses the following components:\n- **TransferController**: Handles requests for Ethereum balance transfers.\n- **TransferService**: Executes the business logic for transferring Ethereum, including balance checks and signing transactions.\n- **BalanceAdaptor**: Fetches the Ethereum balance of the sender.\n- **TransferAdaptor**: Sends signed Ethereum transactions to the blockchain via Web3j.\n\n![ethereum_hexagonal_diagram.png](docs/ethereum_transfer_hexagonal.png)\n\n### Class Diagram\nThis system diagram illustrates the interaction of components during an Ethereum transfer in a Hexagonal Architecture model.\n\n![ethereum_hexagonal_diagram.png](docs/eth_class_diagram.png)\n\n### Sequence Diagram\nThe sequence diagram below details the steps for an Ethereum transfer, including address validation, balance checks, and sending the transaction.\n\n![ethereum_sequence_diagram.png](docs/ethereum_squence_diagram.png)\n\n## Running the Application\nTo run the Crypto API locally, use the following Gradle command:\n\n```bash\n./gradlew :app:bootRun\n```\n# Testing the API\n\nYou can test the API functionality using curl commands as shown below.\n\n## 1. Get Balance\nTo fetch the balance of a Solana wallet, use the following command:\n\n```bash\ncurl --location 'http://localhost:8080/api/v1/balances/p8guAeE7naqQcT2JMCp8Q376MLyzt5XynfGw3uCHM75'\n```\n\n## 2. Transfer SOL\n\nTo transfer SOL between two wallets, use the following command:\n\n```bash\ncurl --location 'http://localhost:8080/api/v1/transfers' \\\n--header 'Content-Type: application/json' \\\n--data '{\n\"to\" : \"81e58SU8EHdBmSnETExsCwurbfWeCbNg9UoAFmKPyyj3\",\n\"amount\" : \"1000\"\n}'\n```\nThis will initiate a transfer of 1000 lamports to the specified wallet address.\n\n## 3.Transfer Ethereum\n\n```bash\ncurl --location 'http://localhost:8080/api/v1/transfers' \\\n--header 'Content-Type: application/json' \\\n--data '{\n\"to\" : \"0x5d940f3947c4ab1fbdbf1f540a10019931065f7a\",\n\"amount\" : \"0.05\"\n}'\n```\n\n## Verifying the Transaction\n\n### Solana Transaction\n\nOnce the transfer has been made, capture the **transaction signature** from the logs.\n\nTo verify the transaction:\n\n1. Go to [Solana Explorer](https://explorer.solana.com/).\n2. Paste the transaction signature into the search bar.\n3. Press Enter to view the transaction details and confirm the transfer status.\n\n![signature.png](docs%2Fsignature.png)\n![transaction.png](docs%2Ftransaction.png)\n\n\n## Solana Transaction Details\n\n### Signature\n- **5xRDwYsgDLMXpkkYLXbvmB66c4ENq9cgZue3S2Fo38FSnf6tCB8VDFNGL77gvRhADX2wzULVwcsCE59ZzyHm7TAZ**\n  - This is the unique transaction identifier, known as the **transaction signature**. It's similar to a receipt ID that you can use to look up and verify the transaction on Solana Explorer.\n\n### Result\n- **Success**\n  - Indicates that the transaction was successfully processed.\n\n### Timestamp\n- **Sep 13, 2024 at 14:44:20 Central European Summer Time**\n  - The exact date and time when the transaction was confirmed on the Solana blockchain, in the specified time zone.\n\n### Confirmation Status\n- **finalized**\n  - This means that the transaction has been permanently included in the blockchain, and all nodes have agreed upon its validity.\n\n### Confirmations\n- **max**\n  - Indicates that the transaction has the maximum number of confirmations possible, ensuring it is fully validated.\n\n### Slot\n- **325,730,164**\n  - A **slot** is a period during which a validator can propose a block. This is the slot number where your transaction was included.\n\n### Recent Blockhash\n- **7DDLsppuoykdpJ168HgZAztzheN9Gehn43BSMCyQBohs**\n  - The blockhash used for this transaction, which ensures that it was included in a specific block of the blockchain. Each transaction is tied to a recent blockhash to prevent replay attacks.\n\n### Fee (SOL)\n- **◎0.000005**\n  - The transaction fee paid for processing the transaction on the Solana blockchain, in SOL. The symbol \"◎\" is commonly used to denote SOL.\n\n### Compute Units Consumed\n- **150**\n  - This represents the amount of computational resources (in units) consumed to process the transaction. More complex transactions may consume more units.\n\n### Transaction Version\n- **legacy**\n  - Refers to the version of the Solana transaction format being used. In this case, it's the \"legacy\" version.\n\n---\n\n### Account Input(s)\nThis section shows the Solana accounts involved in the transaction and how their balances changed.\n\n1. **p8guAeE7naqQcT2JMCp8Q376MLyzt5XynfGw3uCHM75**\n- **Change (SOL):** -◎0.000006 (This account paid the fee for the transaction)\n- **Post Balance (SOL):** ◎1.998435\n- This is the **fee payer** for the transaction, and also the **sender** of the SOL in this transaction.\n\n2. **81e58SU8EHdBmSnETExsCwurbfWeCbNg9UoAFmKPyyj3**\n- **Change (SOL):** +◎0.000001\n- **Post Balance (SOL):** ◎1.00078\n- This is the **recipient** of the transferred SOL.\n\n3. **System Program**\n- This is the built-in Solana program used to handle basic tasks like transferring SOL between accounts.\n\n---\n\n### Instruction\n\n1. **System Program: Transfer**\n- This indicates that the transaction involved the **System Program** for transferring SOL.\n\n- **From Address:** p8guAeE7naqQcT2JMCp8Q376MLyzt5XynfGw3uCHM75 (Sender)\n- **To Address:** 81e58SU8EHdBmSnETExsCwurbfWeCbNg9UoAFmKPyyj3 (Recipient)\n- **Transfer Amount (SOL):** ◎0.000001\n\n- This instruction shows that 0.000001 SOL was transferred from the sender to the recipient.\n\n---\n\n### Program Instruction Logs\n- **Program returned success**\n  - The program responsible for handling the transaction (in this case, the System Program) returned successfully, meaning the transfer was executed without errors.\n\n---\n### Summary\n- The transaction successfully transferred **0.000001 SOL** from the sender to the recipient.\n- A transaction fee of **0.000005 SOL** was charged to the sender.\n- The transaction was **finalized** and is now a permanent part of the Solana blockchain, confirmed at **slot 325,730,164**.\n\n---\n### Ethereum Transaction Details\n\nAfter initiating an Ethereum transfer, you can verify the transaction on the Ethereum blockchain using the transaction hash.\n\ncapture the **transaction signature** from the logs.\n\nTo verify the transaction:\n\n1. Go to [Ether Scan](https://sepolia.etherscan.io/).\n2. Paste the transaction signature into the search bar.\n3. Press Enter to view the transaction details and confirm the transfer status.\n\n![img.png](docs/eth_transaction_details.png)\n\n### Transaction Hash:\n- **0x7dbf2e5864e4db7ea72aa0dd476a35cd3b10a8e9d58b84032286f491484f2abb**\n  - This is the unique identifier for the transaction, which can be used to track and verify it on the Ethereum blockchain via a block explorer like [Etherscan](https://etherscan.io/tx/0x7dbf2e5864e4db7ea72aa0dd476a35cd3b10a8e9d58b84032286f491484f2abb).\n\n### Status:\n- **Success**\n  - The transaction was processed successfully and is now included in the blockchain.\n\n### Block:\n- **6707629**\n  - The transaction was included in this block on the Ethereum blockchain.\n  - A **block** is a group of transactions that were confirmed and added to the blockchain.\n\n### Block Confirmations:\n- **32103 Block Confirmations**\n  - The number of blocks that have been mined since the block containing this transaction. More confirmations make the transaction more secure and harder to reverse.\n\n### Timestamp:\n- **Sep-17-2024 06:49:00 AM UTC** (5 days ago)\n  - This is the exact date and time when the transaction was included in the blockchain.\n\n---\n\n## Parties Involved\n\n### From:\n- **0x4281eCF07378Ee595C564a59048801330f3084eE**\n  - This is the Ethereum address of the **sender** (the account that initiated the transaction and paid for the gas fees).\n\n### To:\n- **0xbd3a24C4447E0AaCdf1000d478186E16Ba2c013A**\n  - This is the Ethereum address of the **recipient** (the account that received the funds).\n\n---\n\n## Transaction Details\n\n### Value:\n- **0.1 ETH**\n  - The amount of Ether (ETH) transferred from the sender to the recipient. In this case, **0.1 ETH** was sent.\n  - **USD Equivalent**: $0.00 (at the time of transaction)\n\n### Transaction Fee:\n- **0.00001187750844 ETH**\n  - The total amount of gas fees paid by the sender to process the transaction.\n  - **USD Equivalent**: $0.00 (at the time of transaction)\n\n### Gas Price:\n- **0.56559564 Gwei** (0.00000000056559564 ETH)\n  - The price per unit of gas paid in Gwei. The **gas price** fluctuates based on network demand and determines how quickly miners will process the transaction.\n\n### Gas Limit \u0026 Usage by Transaction:\n- **Gas Limit**: 60,000\n  - The maximum amount of gas units that the sender was willing to pay for this transaction.\n- **Gas Used**: 21,000\n  - The actual amount of gas consumed by the transaction, which was 35% of the gas limit.\n\n---\n\n## Gas Fees Breakdown\n\n### Gas Fees:\n- **Base Fee**: 0.282877339 Gwei\n  - The base fee is the minimum amount of gas required for this transaction, set by the Ethereum network.\n- **Max Fee**: 0.56559564 Gwei\n  - The maximum gas fee the sender was willing to pay.\n- **Max Priority Fee**: 0.56559564 Gwei\n  - The maximum priority fee offered by the sender to incentivize miners to prioritize this transaction.\n\n### Burnt \u0026 Transaction Savings Fees:\n- 🔥 **Burnt**: 0.000005940424119 ETH\n  - Under **EIP-1559**, part of the gas fee is burned (removed from circulation) to reduce Ethereum supply, making the network deflationary.\n- 💸 **Transaction Savings**: 0 ETH\n  - Any savings from unused gas.\n\n---\n\n## Other Transaction Attributes\n\n### Transaction Type:\n- **2 (EIP-1559)**\n  - This transaction follows the **EIP-1559** standard, which introduced dynamic gas fees and the concept of gas burning.\n\n### Nonce:\n- **1278598**\n  - The transaction nonce is a unique number associated with the sender's account. It represents the number of transactions sent from this address.\n\n### Position in Block:\n- **3**\n  - The transaction was the 3rd transaction included in block **6707629**.\n\n---\n\n### Summary:\n- **0.1 ETH** was successfully transferred from `0x4281eCF07378Ee595C564a59048801330f3084eE` to `0xbd3a24C4447E0AaCdf1000d478186E16Ba2c013A`.\n- The transaction incurred a **fee of 0.00001187750844 ETH**.\n- The transaction used **21,000 gas** out of a **60,000 gas limit**.\n- **0.000005940424119 ETH** was burned as part of the EIP-1559 protocol.\n- The transaction is securely confirmed with **32103 block confirmations**.\n\n\n## Deployed Application\nThe application is deployed and accessible [here](https://crypto-api-production-473a.up.railway.app/swagger-ui/index.html).\n\n### References\n- [Solana Documentation](https://docs.solana.com/)\n- [Solana Explorer](https://explorer.solana.com/)\n- [Solana Whitepaper](https://solana.com/solana-whitepaper.pdf)\n- [Ether Scan](https://sepolia.etherscan.io/)\n- [Quicknode](https://www.quicknode.com/guides/solana-development/getting-started/solana-fundamentals-reference-guide)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuneethkumarck%2Fcrypto-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuneethkumarck%2Fcrypto-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuneethkumarck%2Fcrypto-api/lists"}