시가총액: $2.1732T 0.22%
거래량(24시간): $87.1354B 0.85%
  • 시가총액: $2.1732T 0.22%
  • 거래량(24시간): $87.1354B 0.85%
  • 공포와 탐욕 지수:
  • 시가총액: $2.1732T 0.22%
암호화
주제
암호화
소식
cryptostopics
비디오
최고의 뉴스
암호화
주제
암호화
소식
cryptostopics
비디오
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%

암호화폐 뉴스 기사

Circle의 스마트 계약 플랫폼을 통해 ETH에서 USDC로 원활한 스왑 가능

2024/08/16 13:01

Circle의 스마트 계약 플랫폼은 손쉬운 배포 및 상호 작용을 위해 SDK와 스마트 계약을 통해 ETH에서 USDC로의 교환을 단순화합니다.

Circle의 스마트 계약 플랫폼을 통해 ETH에서 USDC로 원활한 스왑 가능

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

Circle의 스마트 계약 플랫폼을 dApp 또는 애플리케이션에 통합합니다.

Prerequisites

전제 조건

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

Circle 플랫폼을 사용하여 ETH에서 USDC로의 스왑을 진행하기 전에 다음 전제 조건이 충족되는지 확인하세요.

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

Node.js(v16.14.2 이상)가 로컬 머신에 설치되어 있습니다.

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

서클 액세스 키와 비밀 키를 획득하셨습니다. 이러한 키를 생성하는 방법을 알아보려면 Circle 개발자 허브를 참조하세요.

Node Package Manager (NPM) is installed.

NPM(노드 패키지 관리자)이 설치되었습니다.

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.

스마트 계약은 Uniswap과 상호 작용하여 토큰 교환을 수행합니다. ETH를 입금하면 WETH(Wrapped ETH)로 변환되며 Uniswap의 프로토콜을 사용하여 USDC로 스왑될 수 있습니다.

Here's the contract code:

계약 코드는 다음과 같습니다.

// SPDX-License-Identifier: GPL-3.0

// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.17;

프라그마 견고성 0.8.17;

interface IUniswapV2Router02 {

인터페이스 IUniswapV2Router02 {

function swapExactETHForTokens(

함수 swapExactETHForTokens(

uint256 amountOutMin,

uint256 amountOutMin,

address[] calldata path,

주소[] 호출 데이터 경로,

address to,

주소,

uint256 deadline

uint256 기한

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

) 외부 지급 수익(uint256[] 메모리 양);

function WETH() external pure returns (address);

function WETH() 외부 순수 반환(주소);

}

}

contract EthToUsdcSwap {

EthToUsdcSwap 계약 {

IUniswapV2Router02 private constant uniswapRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F248cF);

IUniswapV2Router02 개인 상수 uniswapRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F248cF);

address private constant usdcAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

주소 개인 상수 usdcAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

function swapEthToUsdc(

함수 swapEthToUsdc(

uint256 minUsdcAmount,

uint256 minUsdcAmount,

address to

주소

) external payable {

) 외부 지불 {

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

주소[] 메모리 경로 = 새 주소[](2);

path[0] = uniswapRouter.WETH();

경로[0] = uniswapRouter.WETH();

path[1] = usdcAddress;

경로[1] = usdcAddress;

uniswapRouter.swapExactETHForTokens{value: msg.value}(

uniswapRouter.swapExactETHForTokens{값: msg.값}(

minUsdcAmount,

minUsdc금액,

path,

길,

to,

에게,

block.timestamp + 300

블록.타임스탬프 + 300

);

);

}

}

}

}

Compiling the Smart Contract

스마트 계약 컴파일

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

Remix IDE를 사용하여 계약을 컴파일하고 ABI(Application Binary Interface) 및 바이트코드를 얻습니다.

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.

Circle의 SDK를 사용하여 컴파일된 계약을 배포합니다. 계속하기 전에 터미널이나 스크립트에서 CIRCLE_ACCESS_KEY 및 CIRCLE_SECRET_KEY 환경 변수를 설정했는지 확인하세요.

Here's an example command:

다음은 명령의 예입니다.

npx circle-smart-contracts deploy \

npx 서클-스마트 계약 배포 \

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

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

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

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

--chain="ethereum" \

--chain="이더리움" \

--constructor-args='[]' \

--constructor-args='[]' \

--output-dir="./output"

--output-dir="./output"

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

성공적으로 배포되면 나중에 참조할 수 있도록 contractId 및 transactionId를 받게 됩니다.

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.

계속하기 전에 터미널이나 스크립트에서 CIRCLE_ACCESS_KEY, CIRCLE_SECRET_KEY, CIRCLE_CONTRACT_ID 및 CIRCLE_CHAIN ​​환경 변수를 설정했는지 확인하세요.

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

다음은 0.1 ETH를 USDC로 교환하고 토큰을 지정된 주소로 보내는 명령의 예입니다.

npx circle-smart-contracts interact \

npx 서클-스마트 계약 상호 작용 \

--function="swapEthToUsdc" \

--function="swapEthToUsdc" \

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

--args='[0.1, "0x$(원 지갑)"]' \

--output-dir="./output"

--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.

이 명령은 0.1 ETH의 토큰을 USDC로 스왑하고 스왑된 USDC 토큰을 Circle 개발자 허브에서 볼 수 있는 Circle Pay 지갑으로 보냅니다.

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.

Circle의 스마트 계약 플랫폼은 ETH를 USDC로 교환하기 위한 스마트 계약을 배포하고 관리하기 위한 간소화된 솔루션을 제공합니다. Circle의 SDK를 활용하면 개발자는 쉽게 블록체인에서 트랜잭션을 실행하여 Circle의 서비스를 dApp 또는 애플리케이션에 통합할 수 있습니다.

원본 소스:blockchain

부인 성명:info@kdj.com

제공된 정보는 거래 조언이 아닙니다. kdj.com은 이 기사에 제공된 정보를 기반으로 이루어진 투자에 대해 어떠한 책임도 지지 않습니다. 암호화폐는 변동성이 매우 높으므로 철저한 조사 후 신중하게 투자하는 것이 좋습니다!

본 웹사이트에 사용된 내용이 귀하의 저작권을 침해한다고 판단되는 경우, 즉시 당사(info@kdj.com)로 연락주시면 즉시 삭제하도록 하겠습니다.

2026年06月10日 에 게재된 다른 기사