{"id":255285,"date":"2024-08-18T07:29:23","date_gmt":"2024-08-18T07:29:23","guid":{"rendered":"https:\/\/michigandigitalnews.com\/index.php\/2024\/08\/18\/circles-smart-contract-platform-enables-seamless-eth-to-usdc-swaps\/"},"modified":"2025-06-25T17:12:13","modified_gmt":"2025-06-25T17:12:13","slug":"circles-smart-contract-platform-enables-seamless-eth-to-usdc-swaps","status":"publish","type":"post","link":"https:\/\/michigandigitalnews.com\/index.php\/2024\/08\/18\/circles-smart-contract-platform-enables-seamless-eth-to-usdc-swaps\/","title":{"rendered":"Circle&#8217;s Smart Contract Platform Enables Seamless ETH to USDC Swaps"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div>\n<figure class=\"figure mt-2\">&#13;<br \/>\n                                &#13;<\/p>\n<p>&#13;<br \/>\n                                    <a href=\"https:\/\/blockchain.news\/Profile\/Joerg-Hiller\">Joerg Hiller<\/a>&#13;<br \/>\n                                    <span class=\"publication-date ml-2\"> Aug 16, 2024 04:42<\/span>&#13;\n                                <\/p>\n<p>&#13;<\/p>\n<p class=\"lead\">Circle&#8217;s Smart Contract Platform simplifies ETH to USDC swaps via a smart contract with an SDK for easy deployment and interaction.<\/p>\n<p>&#13;<br \/>\n                                <a href=\"https:\/\/image.blockchain.news:443\/features\/58C560F94F04130770112E2CB6E21C52A7EFFD6CD20603271E090714B2250752.jpg\">&#13;<br \/>\n                                    <img decoding=\"async\" class=\"rounded\" src=\"https:\/\/image.blockchain.news:443\/features\/58C560F94F04130770112E2CB6E21C52A7EFFD6CD20603271E090714B2250752.jpg\" alt=\"Circle's Smart Contract Platform Enables Seamless ETH to USDC Swaps\"\/>&#13;<br \/>\n                                <\/a>&#13;<br \/>\n                            <\/figure>\n<p>Circle&#8217;s Smart Contract Platform now offers a streamlined method for swapping Ethereum (ETH) to USD Coin (USDC) via a smart contract. This development simplifies the process of deploying and interacting with smart contracts, leveraging an SDK that includes wallet and gas abstraction infrastructure, according to Circle.com.<\/p>\n<h2>Prerequisites<\/h2>\n<p>To use Circle&#8217;s platform for ETH to USDC swaps, ensure you have:<\/p>\n<ol>\n<li><a rel=\"nofollow\" href=\"https:\/\/remix.ethereum.org\/\">Remix IDE<\/a> for writing and compiling smart contracts.<\/li>\n<li><a rel=\"nofollow\" href=\"https:\/\/console.circle.com\/signup\">Circle Web3 Services Account<\/a> for managing smart contract interactions.<\/li>\n<li><a rel=\"nofollow\" href=\"https:\/\/developers.circle.com\/w3s\/docs\/developer-controlled-create-your-first-wallet\">Developer Controlled Wallet<\/a> for deploying and executing contract functions.<\/li>\n<\/ol>\n<h2>Writing the Smart Contract<\/h2>\n<p>The smart contract interacts with Uniswap to perform token swaps. When ETH is deposited, it is converted to Wrapped ETH (WETH), which can be swapped for USDC using Uniswap&#8217;s protocol. Below is the contract code:<\/p>\n<pre><code>\n\/\/ SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\nimport '@uniswap\/v3-periphery\/contracts\/libraries\/TransferHelper.sol';\nimport '@uniswap\/v3-periphery\/contracts\/interfaces\/ISwapRouter.sol';\n\ncontract SwapExamples {\n    ISwapRouter public immutable swapRouter;\n    address public constant WETH9 = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619;\n    address public constant USDC = 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359;\n    uint24 public constant poolFee = 3000;\n    \n    constructor(ISwapRouter _swapRouter) {\n        swapRouter = _swapRouter;\n    }\n\n    function swapExactInputSingle(uint256 amountIn) external returns (uint256 amountOut) {\n        TransferHelper.safeTransferFrom(WETH9, msg.sender, address(this), amountIn);\n        TransferHelper.safeApprove(WETH9, address(swapRouter), amountIn);\n        ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({\n            tokenIn: WETH9,\n            tokenOut: USDC,\n            fee: poolFee,\n            recipient: msg.sender,\n            deadline: block.timestamp,\n            amountIn: amountIn,\n            amountOutMinimum: 0,\n            sqrtPriceLimitX96: 0\n        });\n        amountOut = swapRouter.exactInputSingle(params);\n    }\n\n    function swapExactOutputSingle(uint256 amountOut, uint256 amountInMaximum) external returns (uint256 amountIn) {\n        TransferHelper.safeTransferFrom(WETH9, msg.sender, address(this), amountInMaximum);\n        TransferHelper.safeApprove(WETH9, address(swapRouter), amountInMaximum);\n        ISwapRouter.ExactOutputSingleParams memory params = ISwapRouter.ExactOutputSingleParams({\n            tokenIn: WETH9,\n            tokenOut: USDC,\n            fee: poolFee,\n            recipient: msg.sender,\n            deadline: block.timestamp,\n            amountOut: amountOut,\n            amountInMaximum: amountInMaximum,\n            sqrtPriceLimitX96: 0\n        });\n        amountIn = swapRouter.exactOutputSingle(params);\n        if (amountIn &lt; amountInMaximum) {\n            TransferHelper.safeApprove(WETH9, address(swapRouter), 0);\n            TransferHelper.safeTransfer(WETH9, msg.sender, amountInMaximum - amountIn);\n        }\n    }\n}\n<\/code><\/pre>\n<h2>Compiling the Smart Contract<\/h2>\n<p>Use Remix IDE to compile the contract to obtain the ABI (Application Binary Interface) and bytecode:<\/p>\n<ul>\n<li>Create a new file in Remix IDE and paste the smart contract code.<\/li>\n<li>Select the appropriate Solidity compiler version (0.8.20) and compile the contract.<\/li>\n<li>Copy the ABI JSON and bytecode from the &#8220;Compilation Details&#8221; section.<\/li>\n<\/ul>\n<h2>Deploying the Smart Contract<\/h2>\n<p>Deploy the compiled contract using Circle&#8217;s SDK:<\/p>\n<pre><code>\nnpm install @circle-fin\/smart-contract-platform @circle-fin\/developer-controlled-wallets --save\nconst circleContractSdk = require('@circle-fin\/smart-contract-platform');\nconst developerControlledWallets = require('@circle-fin\/developer-controlled-wallets');\n\nconst response = await circleContractSdk.deployContract({\n    name: 'Swap Contract',\n    description: 'Contract for swapping WETH9 to USDC using Uniswap',\n    walletId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91',\n    blockchain: 'MATIC-AMOY',\n    fee: { type: 'level', config: { feeLevel: 'MEDIUM' } },\n    constructorParameters: ['0xYourWalletAddress'],\n    entitySecretCiphertext: '0NtD3d3+nmgb4GqYQXzAjKF8h5Zq6sHM2k\/...',\n    abiJSON: '[...]',\n    bytecode: '0x...'\n});\n<\/code><\/pre>\n<p>Upon successful deployment, you will receive a contractId and transactionId for reference.<\/p>\n<h2>Interacting with the Deployed Contract<\/h2>\n<p>To perform token swaps using the deployed contract:<\/p>\n<pre><code>\nconst response = await circleDeveloperSdk.createContractExecutionTransaction({\n    walletId: 'ce714f5b-0d8e-4062-9454-61aa1154869b',\n    contractAddress: '0x2f3A40A3db8a7e3D09B0adfEfbCe4f6F81927557',\n    abiFunctionSignature: 'swapExactInputSingle(uint256)',\n    abiParameters: [1000],\n    fee: { type: 'level', config: { feeLevel: 'MEDIUM' } }\n});\n<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>Circle&#8217;s Smart Contract Platform provides an efficient solution for deploying and managing smart contracts to swap ETH to USDC. By leveraging Circle&#8217;s SDK, developers can easily execute transactions on the blockchain.<\/p>\n<p><a rel=\"nofollow\" href=\"https:\/\/www.circle.com\/blog\/how-to-swap-eth-for-usdc-with-circles-smart-contract-platform\">Source<\/a><\/p>\n<p><span><i>Image source: Shutterstock<\/i><\/span><\/p>\n<p>                            <!-- Divider --><\/p>\n<p>                            <!-- Author info END --><br \/>\n                            <!-- Divider --><\/p><\/div>\n<p>[ad_2]<br \/>\n<br \/><a href=\"https:\/\/blockchain.news\/news\/circle-smart-contract-platform-enables-eth-to-usdc-swaps\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] &#13; &#13; &#13; Joerg Hiller&#13; Aug 16, 2024 04:42&#13; &#13; Circle&#8217;s Smart Contract Platform simplifies ETH to USDC swaps via a smart contract with<\/p>\n","protected":false},"author":1,"featured_media":255286,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[171],"tags":[],"_links":{"self":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/255285"}],"collection":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/comments?post=255285"}],"version-history":[{"count":0,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/255285\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media\/255286"}],"wp:attachment":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media?parent=255285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/categories?post=255285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/tags?post=255285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}