Marktkapitalisierung: $2.2391T 1.66%
Volumen (24h): $47.003B 22.54%
  • Marktkapitalisierung: $2.2391T 1.66%
  • Volumen (24h): $47.003B 22.54%
  • Angst- und Gier-Index:
  • Marktkapitalisierung: $2.2391T 1.66%
Kryptos
Themen
Cryptospedia
Nachricht
Cryptostopics
Videos
Top -Nachrichten
Kryptos
Themen
Cryptospedia
Nachricht
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%

Nachrichtenartikel zu Kryptowährungen

Die Smart-Contract-Plattform von Circle ermöglicht nahtlose ETH-zu-USDC-Swaps

Aug 16, 2024 at 01:01 pm

Die Smart Contract Platform von Circle vereinfacht den Austausch von ETH zu USDC über einen Smart Contract mit einem SDK für eine einfache Bereitstellung und Interaktion.

Die Smart-Contract-Plattform von Circle ermöglicht nahtlose ETH-zu-USDC-Swaps

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

Integrieren Sie die Smart Contract Platform von Circle in ihre dApps oder Anwendungen.

Prerequisites

Voraussetzungen

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

Bevor Sie mit dem ETH-zu-USDC-Swap über die Circle-Plattform fortfahren, stellen Sie sicher, dass die folgenden Voraussetzungen erfüllt sind:

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

Node.js (v16.14.2 oder höher) ist auf Ihrem lokalen Computer installiert.

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

Sie haben einen Circle-Zugangsschlüssel und einen Geheimschlüssel erhalten. Informationen zum Generieren dieser Schlüssel finden Sie im Circle Developer Hub.

Node Package Manager (NPM) is installed.

Der Node Package Manager (NPM) ist installiert.

Writing the Smart Contract

Den Smart Contract schreiben

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.

Der Smart Contract interagiert mit Uniswap, um den Token-Austausch durchzuführen. Bei der Einzahlung der ETH wird diese in Wrapped ETH (WETH) umgewandelt und kann mithilfe des Uniswap-Protokolls gegen USDC getauscht werden.

Here's the contract code:

Hier ist der Vertragscode:

// SPDX-License-Identifier: GPL-3.0

// SPDX-Lizenz-Identifikator: GPL-3.0

pragma solidity 0.8.17;

Pragma-Stabilität 0.8.17;

interface IUniswapV2Router02 {

Schnittstelle IUniswapV2Router02 {

function swapExactETHForTokens(

Funktion swapExactETHForTokens(

uint256 amountOutMin,

uint256 amountOutMin,

address[] calldata path,

Adresse[] Anrufdatenpfad,

address to,

Adresse an,

uint256 deadline

uint256 Frist

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

) extern zahlbare Rückgaben (uint256[] Speicherbeträge);

function WETH() external pure returns (address);

Funktion WETH() external pure gibt (Adresse) zurück;

}

}

contract EthToUsdcSwap {

Vertrag EthToUsdcSwap {

IUniswapV2Router02 private constant uniswapRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F248cF);

IUniswapV2Router02 private Konstante uniswapRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F248cF);

address private constant usdcAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

private Adresskonstante usdcAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

function swapEthToUsdc(

Funktion swapEthToUsdc(

uint256 minUsdcAmount,

uint256 minUsdcAmount,

address to

Adresse an

) external payable {

) externe Verbindlichkeit {

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

Adresse[] Speicherpfad = neue Adresse[](2);

path[0] = uniswapRouter.WETH();

path[0] = uniswapRouter.WETH();

path[1] = usdcAddress;

path[1] = usdcAddress;

uniswapRouter.swapExactETHForTokens{value: msg.value}(

uniswapRouter.swapExactETHForTokens{value: msg.value}(

minUsdcAmount,

minUsdcAmount,

path,

Weg,

to,

Zu,

block.timestamp + 300

block.timestamp + 300

);

);

}

}

}

}

Compiling the Smart Contract

Kompilieren des Smart Contracts

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

Verwenden Sie die Remix-IDE, um den Vertrag zu kompilieren und die ABI (Application Binary Interface) und den Bytecode abzurufen.

Deploying the Smart Contract

Bereitstellung des Smart Contracts

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.

Verwenden Sie das SDK von Circle, um den kompilierten Vertrag bereitzustellen. Bevor Sie fortfahren, stellen Sie sicher, dass Sie die Umgebungsvariablen CIRCLE_ACCESS_KEY und CIRCLE_SECRET_KEY in Ihrem Terminal oder Skript festgelegt haben.

Here's an example command:

Hier ist ein Beispielbefehl:

npx circle-smart-contracts deploy \

Npx Circle-Smart-Contracts bereitstellen \

--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="ethereum" \

--constructor-args='[]' \

--constructor-args='[]' \

--output-dir="./output"

--output-dir="./output"

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

Nach erfolgreicher Bereitstellung erhalten Sie eine Vertrags-ID und eine Transaktions-ID zur späteren Bezugnahme.

Interacting with the Deployed Contract

Interaktion mit dem bereitgestellten Vertrag

To perform token swaps using the deployed contract:

So führen Sie Token-Austausche mithilfe des bereitgestellten Vertrags durch:

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.

Bevor Sie fortfahren, stellen Sie sicher, dass Sie die Umgebungsvariablen CIRCLE_ACCESS_KEY, CIRCLE_SECRET_KEY, CIRCLE_CONTRACT_ID und CIRCLE_CHAIN ​​in Ihrem Terminal oder Skript festgelegt haben.

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

Hier ist ein Beispielbefehl, um 0,1 ETH in USDC zu tauschen und die Token an die angegebene Adresse zu senden:

npx circle-smart-contracts interact \

Npx Circle-Smart-Contracts interagieren \

--function="swapEthToUsdc" \

--function="swapEthToUsdc" \

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

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

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

Dieser Befehl führt einen Token-Tausch von 0,1 ETH zu USDC durch und sendet die getauschten USDC-Token an Ihr Circle Pay-Wallet, das im Circle Developer Hub eingesehen werden kann.

Conclusion

Abschluss

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.

Die Smart Contract Platform von Circle bietet eine optimierte Lösung für die Bereitstellung und Verwaltung intelligenter Verträge zum Tausch von ETH in USDC. Durch die Nutzung des SDK von Circle können Entwickler problemlos Transaktionen auf der Blockchain ausführen, um die Dienste von Circle in ihre dApps oder Anwendungen zu integrieren.

Originalquelle:blockchain

Haftungsausschluss:info@kdj.com

Die bereitgestellten Informationen stellen keine Handelsberatung dar. kdj.com übernimmt keine Verantwortung für Investitionen, die auf der Grundlage der in diesem Artikel bereitgestellten Informationen getätigt werden. Kryptowährungen sind sehr volatil und es wird dringend empfohlen, nach gründlicher Recherche mit Vorsicht zu investieren!

Wenn Sie glauben, dass der auf dieser Website verwendete Inhalt Ihr Urheberrecht verletzt, kontaktieren Sie uns bitte umgehend (info@kdj.com) und wir werden ihn umgehend löschen.

Weitere Artikel veröffentlicht am Jul 28, 2026