읽는 데 2분
개요
이더리움 애플리케이션은 다양한 프로그래밍 언어로 개발할 수 있습니다. 이 글에서는 파이썬을 사용하여 이더리움 네트워크에 연결해 보겠습니다.
Prerequisite
- Ethereum Node (We will use Quicknode’s free version)
- Python installed in your system (version >=3.5.3) and Pip3
- Install web3.py (A Python wrapper for Ethereum node APIs)
- 텍스트 편집기
Note: We need Python version >=3.5.3 and install web3.py using pip3 install web3.
Python and other library versions are the cause of the common installation problems. Therefore, if you face any problem, try setting up a virtual environment and troubleshoot web3.py installation.
Connecting to Ethereum Blockchain
A network of Ethereum nodes is called Ethereum blockchain. To interact with Etherum blockchain, these nodes expose APIs which are available using web3.py library.
In addition, we will need a running Ethereum node, therefore, we will connect to one using Quicknode’s Free Trial plan. Sign up here and create an Ethereum endpoint.

We will use web3.py to get the latest Ethereum block number. For this, we will use the code snippet given below.
from web3 import Web3, HTTPProvider
w3 = Web3(HTTPProvider('YOUR_ETHEREUM_NODE_URL'))
print ("Latest Ethereum block number" , w3.eth.blockNumber)
In this snippet, we are importing web3.py library and adding our Ethereum node URL and getting the latest Ethereum block number using w3.eth.blockNumber API.
Now, we will save this code snippet in index.py file and then run it using python index.py command. After running this command we will see the latest Ethereum block number as shown below.

That’s it you have connected through the Ethereum network using Python. In addition, you can learn more web3.py APIs to build complex applications on Ethereum.
여러분의 피드백을 ❤️ 환영합니다!
의견이나 다루었으면 하는 새로운 주제가 있다면 알려주세요. 여러분의 의견을 기다리고 있습니다.