import json from web3 import Web3 # Ethereum 노드에 연결 (Infura나 Alchemy 같은 서비스 사용) infura_url = 'https://mainnet.infura.io/v3/16185d569adf4d00a04f2d2a200cf231' web3 = Web3(Web3.HTTPProvider(infura_url)) # 지갑 주소와 프라이빗 키 sender_address = '0x9526E51ee3D9bA02Ef674eB1E41FB24Dc2165380' sender_private_key = '740e61590a4b047aeba4a416fe8155572d28c4a91759fa0596bd9f31e06b386f' receiver_address = '0x7BC5706471B71547566ACd445e9B6e7f6CE79eF1' nft_contract_address = '0xA4B37bE40F7b231Ee9574c4b16b7DDb7EAcDC99B' token_id = 3493792 # 전송할 NFT의 토큰 ID erc721_abi = [ { "constant": False, "inputs": [ { "name": "from", "type": "address" }, { "name": "to", "type": "address" }, { "name": "tokenId", "type": "uint256" } ], "name": "transferFrom", "outputs": [], "type": "function" } ] # NFT 컨트랙트 인스턴스 생성 nft_contract = web3.eth.contract(address=nft_contract_address, abi=erc721_abi) # 전송 트랜잭션 생성 transaction = nft_contract.functions.transferFrom(sender_address, receiver_address, token_id).build_transaction({ 'from': sender_address, 'nonce': web3.eth.get_transaction_count(sender_address), 'gas': 21000, # 가스 한도 'maxFeePerGas': web3.toWei('30.015832944', 'gwei'), # 최대 기본 요금 'maxPriorityFeePerGas': web3.toWei('30', 'gwei') # 우선 요금 }) # 트랜잭션 서명 signed_transaction = web3.eth.account.signTransaction(transaction, sender_private_key) # 트랜잭션 전송 tx_hash = web3.eth.sendRawTransaction(signed_transaction.rawTransaction) # 트랜잭션 해시 출력 print(f'Transaction hash: {web3.toHex(tx_hash)}')