Skip to content

Commit e9119ca

Browse files
DavidRomanovizcfselmo
authored andcommitted
✨ add eth_blobBaseFee:
- 📝 add docs for eth_blobBaseFee - 📝 add newsfragments - 🧪 add test for eth_blobBaseFee
1 parent c3b6692 commit e9119ca

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

docs/web3.eth.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ The following methods are available on the ``web3.eth`` namespace.
200200
>>> web3.eth.get_storage_at('0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B', 0)
201201
'0x00000000000000000000000000000000000000000000000000120a0b063499d4'
202202
203+
.. py:method:: Eth.blob_base_fee
204+
205+
Fetches the expected base fee for blobs in the next block.
206+
207+
* Delegates to ``eth_blobBaseFee`` RPC Method
208+
209+
Returns the expected base fee in Wei.
210+
211+
.. code-block:: python
212+
213+
>>> web3.eth.blob_base_fee()
214+
537070730
215+
203216
204217
.. py:method:: Eth.get_proof(account, positions, block_identifier=eth.default_block)
205218

newsfragments/3527.feature.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Support for ``w3.eth.blob_base_fee``
2+
- Async support for ``w3.eth.blob_base_fee``

web3/_utils/method_formatters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ def subscription_formatter(value: Any) -> Union[HexBytes, HexStr, Dict[str, Any]
836836
PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
837837
# Eth
838838
RPC.eth_accounts: apply_list_to_array_formatter(to_checksum_address),
839+
RPC.eth_blobBaseFee: to_integer_if_hex,
839840
RPC.eth_blockNumber: to_integer_if_hex,
840841
RPC.eth_chainId: to_integer_if_hex,
841842
RPC.eth_call: HexBytes,

web3/_utils/module_testing/eth_module.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,11 @@ def test_eth_accounts(self, w3: "Web3") -> None:
26132613
assert len(accounts) != 0
26142614
assert all(is_checksum_address(account) for account in accounts)
26152615

2616+
def test_eth_blob_base_fee(self, w3: "Web3") -> None:
2617+
blob_base_fee = w3.eth.blob_base_fee
2618+
assert is_integer(blob_base_fee)
2619+
assert blob_base_fee >= 0
2620+
26162621
def test_eth_block_number(self, w3: "Web3") -> None:
26172622
block_number = w3.eth.block_number
26182623
assert is_integer(block_number)

web3/_utils/rpc_abi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class RPC:
4848

4949
# eth
5050
eth_accounts = RPCEndpoint("eth_accounts")
51+
eth_blobBaseFee = RPCEndpoint("eth_blobBaseFee")
5152
eth_blockNumber = RPCEndpoint("eth_blockNumber")
5253
eth_call = RPCEndpoint("eth_call")
5354
eth_createAccessList = RPCEndpoint("eth_createAccessList")

web3/eth/async_eth.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ class AsyncEth(BaseEth):
127127
async def accounts(self) -> Tuple[ChecksumAddress]:
128128
return await self._accounts()
129129

130+
# eth_blobBaseFee
131+
132+
_eth_blobBaseFee: Method[Callable[[], Awaitable[Wei]]] = Method(
133+
RPC.eth_blobBaseFee,
134+
is_property=True,
135+
)
136+
137+
@property
138+
async def blob_base_fee(self) -> Wei:
139+
return await self._eth_blobBaseFee()
140+
130141
# eth_blockNumber
131142

132143
get_block_number: Method[Callable[[], Awaitable[BlockNumber]]] = Method(

web3/eth/eth.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ class Eth(BaseEth):
119119
def accounts(self) -> Tuple[ChecksumAddress]:
120120
return self._accounts()
121121

122+
# eth_blobBaseFee
123+
124+
_eth_blobBaseFee: Method[Callable[[], Wei]] = Method(
125+
RPC.eth_blobBaseFee,
126+
is_property=True,
127+
)
128+
129+
@property
130+
def blob_base_fee(self) -> Wei:
131+
return self._eth_blobBaseFee()
132+
122133
# eth_blockNumber
123134

124135
get_block_number: Method[Callable[[], BlockNumber]] = Method(

0 commit comments

Comments
 (0)