Hello world! Welcome to the 2nd edition of the Web3 Python Weekly. Each week we’ll bring you one tweet, video, tool, and exercise to keep you up to date on all things happening at the crossroads of Web3 & python. Take a break from your deep work, let’s catch up!
word1 = "let's"
word2 = "rock"
word3 = "and roll"
print(word1 + " " + word2 " " + word3)
Python Crypto API Wrappers (pycaw) by Unique Divine
Pycaw is a package for interacting with popular Crypto APIs like Etherscan, Messari, and CoinGecko in combination with certain functionality from web3.py.
### Summary of pycaw features
・ Functions available for REST APIs available on Etherscan, FTMSan, Messari, DefiLlama, CoinGecko, and CoinMarketCap. This makes it easy to retrieve gas prices, token prices, event logs given some transaction hash or contract address over some window of blocks.
・ Parses responses into strongly typed classes
・ Eases queries and management of of events and interactions with Ethereum smart contract ABIs.
The pycaw
package was born out of necessity to create a mini indexer using pure Python to retrieve airdrop data and to monitor performance, deposits, and withdrawals of vault contracts. This was possible because of the events emitted during transaction execution.
Smart contracts are stored on Ethereum as bytecode. An application binary interface (ABI) allows one to convert between bytecode and names and types that can be interpreted by high-level languages like JavaScript, Vyper, Solidity, and Python. Usually, this ABI is a JSON file of functions, arguments and declarations.
With pycaw
, you can query ABIs directly using a contract address (or retrieve the contract address from a transaction or account), and decode events using the etherscan
subpackage. The reason contracts written in Vyper can interact with those written in Solidity is because of ABIs.
How to get started with Pycaw
You can install the package from PyPI.
pip install python-caw
Inside programs, you import it as pycaw:
import pycaw
from pycaw import etherscan
More information can be found here:
Curve Vyper Tutorial Lesson 1
Python Smart Contracts: By The Numbers
That's it for today & see ya next time! If you liked this issue, be sure to share!