時価総額: $2.1791T 0.85%
ボリューム(24時間): $88.1449B 1.33%
  • 時価総額: $2.1791T 0.85%
  • ボリューム(24時間): $88.1449B 1.33%
  • 恐怖と貪欲の指数:
  • 時価総額: $2.1791T 0.85%
暗号
トピック
暗号化
ニュース
暗号造園
動画
トップニュース
暗号
トピック
暗号化
ニュース
暗号造園
動画
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 Access Key と Secret Key を取得しました。これらのキーを生成する方法については、Circle Developer Hub を参照してください。

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 を入金すると、Wrapped ETH (WETH) に変換され、Uniswap のプロトコルを使用して USDC と交換できます。

Here's the contract code:

契約コードは次のとおりです。

// SPDX-License-Identifier: GPL-3.0

// SPDX ライセンス識別子: GPL-3.0

pragma solidity 0.8.17;

プラグマソリッドティ0.8.17;

interface IUniswapV2Router02 {

インターフェース IUniswapV2Router02 {

function swapExactETHForTokens(

関数 swapExactETHForTokens(

uint256 amountOutMin,

uint256 出力最小値、

address[] calldata path,

address[] calldata パス、

address to,

宛先、

uint256 deadline

uint256 期限

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

) 外部買掛金リターン (uint256[] メモリ量);

function WETH() external pure returns (address);

関数 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 分米ドル金額、

address to

宛先

) external payable {

) 外部支払 {

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

address[] メモリ パス = 新しいアドレス [](2);

path[0] = uniswapRouter.WETH();

パス[0] = uniswapRouter.WETH();

path[1] = usdcAddress;

パス[1] = usdcアドレス;

uniswapRouter.swapExactETHForTokens{value: msg.value}(

uniswapRouter.swapExactETHForTokens{値: msg.value}(

minUsdcAmount,

最小米ドル金額、

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

このコマンドは、USDC への 0.1 ETH のトークン スワップを実行し、スワップされた USDC トークンを Circle Pay ウォレットに送信します。これは 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.

Circle のスマート コントラクト プラットフォームは、ETH を USDC に交換するためのスマート コントラクトを展開および管理するための合理化されたソリューションを提供します。 Circle の SDK を活用することで、開発者はブロックチェーン上でトランザクションを簡単に実行し、Circle のサービスを dApp やアプリケーションに統合できます。

オリジナルソース:blockchain

免責事項:info@kdj.com

提供される情報は取引に関するアドバイスではありません。 kdj.com は、この記事で提供される情報に基づいて行われた投資に対して一切の責任を負いません。暗号通貨は変動性が高いため、十分な調査を行った上で慎重に投資することを強くお勧めします。

このウェブサイトで使用されているコンテンツが著作権を侵害していると思われる場合は、直ちに当社 (info@kdj.com) までご連絡ください。速やかに削除させていただきます。

2026年06月10日 に掲載されたその他の記事