import { AlchemyProvider, Wallet } from 'ethers'; // 1. 네트워크와 API 키 설정 const network = 'matic-amoy'; // Polygon Amoy 테스트넷 const alchemyApiKey = 'o5F9YD_LHZZEde-gXzZyv'; // 여기에 본인의 API 키 입력 // 2. Alchemy Provider 생성 const provider = new AlchemyProvider(network, alchemyApiKey); // 3. 지갑 연결 (테스트용 private key 사용) const privateKey = 'ccb3131e009c579f16e6088f89218744f670e9b09c28514c671d5ae239f0c532'; // 절대 실제 자산이 있는 키 사용 금지! const wallet = new Wallet(privateKey, provider); // 4. 예제: 지갑 주소와 잔액 출력 async function main() { const address = await wallet.getAddress(); const balance = await provider.getBalance(address); console.log(`🪪 Address: ${address}`); console.log(`🪪 Balance: ${balance}`); //console.log(`💰 Balance: ${ethers.formatEther(balance)} MATIC`); } main().catch(console.error);