Market Cap: $2.2274T 1.22%
Volume(24h): $43.1719B 13.79%
  • Market Cap: $2.2274T 1.22%
  • Volume(24h): $43.1719B 13.79%
  • Fear & Greed Index:
  • Market Cap: $2.2274T 1.22%
Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos
Top News
Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos
bitcoin
bitcoin

$87959.907984 USD

1.34%

ethereum
ethereum

$2920.497338 USD

3.04%

tether
tether

$0.999775 USD

0.00%

xrp
xrp

$2.237324 USD

8.12%

bnb
bnb

$860.243768 USD

0.90%

solana
solana

$138.089498 USD

5.43%

usd-coin
usd-coin

$0.999807 USD

0.01%

tron
tron

$0.272801 USD

-1.53%

dogecoin
dogecoin

$0.150904 USD

2.96%

cardano
cardano

$0.421635 USD

1.97%

hyperliquid
hyperliquid

$32.152445 USD

2.23%

bitcoin-cash
bitcoin-cash

$533.301069 USD

-1.94%

chainlink
chainlink

$12.953417 USD

2.68%

unus-sed-leo
unus-sed-leo

$9.535951 USD

0.73%

zcash
zcash

$521.483386 USD

-2.87%

Cryptocurrency News Articles

Circle's Smart Contract Platform Enables Seamless ETH to USDC Swaps

Aug 16, 2024 at 01:01 pm

Circle's Smart Contract Platform simplifies ETH to USDC swaps via a smart contract with an SDK for easy deployment and interaction.

Circle's Smart Contract Platform Enables Seamless ETH to USDC Swaps

integrate Circle's Smart Contract Platform into their dApps or applications.

Prerequisites

Before proceeding with the ETH to USDC swaps using Circle's platform, ensure the following prerequisites are met:

Node.js (v16.14.2 or later) is installed on your local machine.

You have obtained a Circle Access Key and Secret Key. To learn how to generate these keys, refer to the Circle Developer Hub.

Node Package Manager (NPM) is installed.

Writing the Smart Contract

The smart contract will interact with Uniswap to perform the token swaps. Upon depositing ETH, it is converted to Wrapped ETH (WETH) and can be swapped for USDC using Uniswap's protocol.

Here's the contract code:

// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.17;

interface IUniswapV2Router02 {

function swapExactETHForTokens(

uint256 amountOutMin,

address[] calldata path,

address to,

uint256 deadline

) external payable returns (uint256[] memory amounts);

function WETH() external pure returns (address);

}

contract EthToUsdcSwap {

IUniswapV2Router02 private constant uniswapRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F248cF);

address private constant usdcAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

function swapEthToUsdc(

uint256 minUsdcAmount,

address to

) external payable {

address[] memory path = new address[](2);

path[0] = uniswapRouter.WETH();

path[1] = usdcAddress;

uniswapRouter.swapExactETHForTokens{value: msg.value}(

minUsdcAmount,

path,

to,

block.timestamp + 300

);

}

}

Compiling the Smart Contract

Use Remix IDE to compile the contract and obtain the ABI (Application Binary Interface) and bytecode.

Deploying the Smart Contract

Use Circle's SDK to deploy the compiled contract. Before proceeding, ensure you have set the CIRCLE_ACCESS_KEY and CIRCLE_SECRET_KEY environment variables in your terminal or script.

Here's an example command:

npx circle-smart-contracts deploy

--abi="./build/contracts/EthToUsdcSwap.sol/EthToUsdcSwap.json"

--bytecode="0x$(cat build/contracts/EthToUsdcSwap.sol/EthToUsdcSwap.bin)"

--chain="ethereum"

--constructor-args='[]'

--output-dir="./output"

Upon successful deployment, you will receive a contractId and transactionId for future reference.

Interacting with the Deployed Contract

To perform token swaps using the deployed contract:

Before proceeding, ensure you have set the CIRCLE_ACCESS_KEY, CIRCLE_SECRET_KEY, CIRCLE_CONTRACT_ID, and CIRCLE_CHAIN environment variables in your terminal or script.

Here's an example command to swap 0.1 ETH to USDC and send the tokens to the specified address:

npx circle-smart-contracts interact

--function="swapEthToUsdc"

--args='[0.1, "0x$(circle-wallet)"]'

--output-dir="./output"

This command will perform a token swap of 0.1 ETH to USDC and send the swapped USDC tokens to your Circle Pay wallet, which can be viewed in the Circle Developer Hub.

Conclusion

Circle's Smart Contract Platform offers a streamlined solution for deploying and managing smart contracts to swap ETH to USDC. By leveraging Circle's SDK, developers can easily execute transactions on the blockchain to integrate Circle's services into their dApps or applications.

Original source:blockchain

Disclaimer:info@kdj.com

The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!

If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.

Other articles published on Jul 28, 2026