fastweb3-objects 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. fastweb3_objects-0.1.0/LICENSE +21 -0
  2. fastweb3_objects-0.1.0/PKG-INFO +233 -0
  3. fastweb3_objects-0.1.0/README.md +203 -0
  4. fastweb3_objects-0.1.0/pyproject.toml +63 -0
  5. fastweb3_objects-0.1.0/setup.cfg +4 -0
  6. fastweb3_objects-0.1.0/src/fastweb3_objects.egg-info/PKG-INFO +233 -0
  7. fastweb3_objects-0.1.0/src/fastweb3_objects.egg-info/SOURCES.txt +25 -0
  8. fastweb3_objects-0.1.0/src/fastweb3_objects.egg-info/dependency_links.txt +1 -0
  9. fastweb3_objects-0.1.0/src/fastweb3_objects.egg-info/requires.txt +19 -0
  10. fastweb3_objects-0.1.0/src/fastweb3_objects.egg-info/top_level.txt +1 -0
  11. fastweb3_objects-0.1.0/src/fw3_objects/__init__.py +12 -0
  12. fastweb3_objects-0.1.0/src/fw3_objects/abi.py +511 -0
  13. fastweb3_objects-0.1.0/src/fw3_objects/account.py +407 -0
  14. fastweb3_objects-0.1.0/src/fw3_objects/cache/__init__.py +1 -0
  15. fastweb3_objects-0.1.0/src/fw3_objects/cache/db.py +73 -0
  16. fastweb3_objects-0.1.0/src/fw3_objects/cache/metadata.py +89 -0
  17. fastweb3_objects-0.1.0/src/fw3_objects/cache/rpc.py +205 -0
  18. fastweb3_objects-0.1.0/src/fw3_objects/chain.py +317 -0
  19. fastweb3_objects-0.1.0/src/fw3_objects/contract.py +647 -0
  20. fastweb3_objects-0.1.0/src/fw3_objects/errors.py +92 -0
  21. fastweb3_objects-0.1.0/src/fw3_objects/events.py +379 -0
  22. fastweb3_objects-0.1.0/src/fw3_objects/explorers/__init__.py +1 -0
  23. fastweb3_objects-0.1.0/src/fw3_objects/explorers/blockscout.py +83 -0
  24. fastweb3_objects-0.1.0/src/fw3_objects/explorers/etherscan.py +96 -0
  25. fastweb3_objects-0.1.0/src/fw3_objects/explorers/lookup.py +267 -0
  26. fastweb3_objects-0.1.0/src/fw3_objects/monitor.py +125 -0
  27. fastweb3_objects-0.1.0/src/fw3_objects/transaction.py +348 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 iamdefinitelyahuman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastweb3-objects
3
+ Version: 0.1.0
4
+ Summary: High-level objects built on fastweb3.
5
+ Author: iamdefinitelyahuman
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/iamdefinitelyahuman/fastweb3-objects
8
+ Project-URL: Repository, https://github.com/iamdefinitelyahuman/fastweb3-objects
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: eth-stdlib<0.3,>=0.2.7
13
+ Requires-Dist: fastweb3<0.2.0,>=0.1.6
14
+ Requires-Dist: fastweb3-keypass<0.2.0,>=0.1.2
15
+ Requires-Dist: platformdirs>=4.0
16
+ Requires-Dist: pycryptodome>=3.20
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=8; extra == "dev"
19
+ Requires-Dist: pytest-cov>=5; extra == "dev"
20
+ Requires-Dist: ruff>=0.9; extra == "dev"
21
+ Requires-Dist: pre-commit>=3; extra == "dev"
22
+ Requires-Dist: build; extra == "dev"
23
+ Requires-Dist: twine; extra == "dev"
24
+ Requires-Dist: mkdocs>=1.6; extra == "dev"
25
+ Requires-Dist: mkdocs-material>=9.5; extra == "dev"
26
+ Provides-Extra: docs
27
+ Requires-Dist: mkdocs>=1.6; extra == "docs"
28
+ Requires-Dist: mkdocs-material>=9.5; extra == "docs"
29
+ Dynamic: license-file
30
+
31
+ # fastweb3-objects
32
+
33
+ High-level EVM objects built on `fastweb3`.
34
+
35
+ NOTE: This library is still in early alpha development. Prior to a `v1.0.0` (which may never come), expect breaking changes and no backward compatibility between versions.
36
+
37
+ ## Installation
38
+
39
+ You can install the latest release via `pip`:
40
+
41
+ pip install fastweb3-objects
42
+
43
+ Or clone the repository for the most up-to-date version:
44
+
45
+ git clone https://github.com/iamdefinitelyahuman/fastweb3-objects.git
46
+ cd fastweb3-objects
47
+ pip install -e .
48
+
49
+ ## Usage
50
+
51
+ The main entry points are available directly from `fw3_objects`:
52
+
53
+ >>> from fw3_objects import Account, Accounts, Chain, Contract, Transaction
54
+
55
+ ### 1. Connect to a chain
56
+
57
+ `Chain` is the canonical object for interacting with a specific EVM chain.
58
+
59
+ >>> chain = Chain(1)
60
+ >>> chain
61
+ Chain(1)
62
+
63
+ The underlying `fastweb3.Web3` client is created lazily. By default, it uses `fastweb3`'s public RPC discovery and endpoint pooling.
64
+
65
+ >>> chain.height()
66
+ 23100000
67
+
68
+ You can access blocks by number, hash, tag, or index syntax:
69
+
70
+ >>> chain.get_block("latest")
71
+ {'number': 23100000, ...}
72
+
73
+ >>> chain[-1]
74
+ {'number': 23100000, ...}
75
+
76
+ To use your own RPC endpoint, configure the chain before first use:
77
+
78
+ >>> from fw3_objects.chain import configure_chain
79
+
80
+ >>> configure_chain(1, endpoints=["http://localhost:8545"], use_public_pool=False)
81
+ >>> chain = Chain(1)
82
+
83
+ ### 2. Use a default chain context
84
+
85
+ Objects can be bound explicitly to a chain, or they can use the active default chain.
86
+
87
+ >>> mainnet = Chain(1)
88
+
89
+ >>> with mainnet.as_default():
90
+ ... vitalik = Account("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
91
+ ... vitalik.balance()
92
+ ...
93
+ 32131215082101779377
94
+
95
+ Strict mode rejects accidental access through another chain while the context is active.
96
+
97
+ >>> with mainnet.as_default(strict=True):
98
+ ... Account("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045").balance()
99
+
100
+ ### 3. Manage accounts
101
+
102
+ `Accounts` is a `fastweb3-keypass` database wrapper. With no arguments, it opens the default database, creating it first if needed.
103
+
104
+ >>> accounts = Accounts()
105
+ Create password for new Accounts database 'default': ***
106
+
107
+ >>> accounts
108
+ <Accounts unlocked>
109
+
110
+ Accounts created or imported through the database can sign transactions.
111
+
112
+ >>> acct = accounts.create_account(alias="deployer", set_as_default=True)
113
+ >>> acct
114
+ <Account 0x0D3AaC9458167352493864Af54D1CBD7F1B8fF68 signable>
115
+
116
+ You can also create watch-only account objects directly from an address.
117
+
118
+ >>> vitalik = Account("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", chain=1)
119
+ >>> vitalik
120
+ <Account 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 watch-only>
121
+
122
+ Chain-aware account helpers expose common RPC operations.
123
+
124
+ >>> vitalik.balance()
125
+ 32131215082101779377
126
+
127
+ >>> vitalik.nonce()
128
+ 1832
129
+
130
+ >>> vitalik.bytecode()
131
+ b''
132
+
133
+ ### 4. Send transactions
134
+
135
+ Signing accounts can build, sign, broadcast, and watch transactions in a single call.
136
+
137
+ >>> tx = acct.transact(
138
+ ... to="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
139
+ ... value=10**18,
140
+ ... chain=1,
141
+ ... )
142
+
143
+ The returned `Transaction` object tracks mempool, receipt, replacement, and revert state.
144
+
145
+ >>> tx.status
146
+ <TxStatus.PENDING: -1>
147
+
148
+ >>> tx.wait()
149
+ >>> tx.status
150
+ <TxStatus.CONFIRMED: 1>
151
+
152
+ >>> tx.block_number
153
+ 23100012
154
+
155
+ >>> tx.gas_used
156
+ 21000
157
+
158
+ Pending transactions can be replaced with a higher-fee transaction when the sender is available in an open `Accounts` database.
159
+
160
+ >>> replacement = tx.replace()
161
+
162
+ ### 5. Interact with contracts
163
+
164
+ `Contract` binds an address, ABI, and chain. ABI can be provided directly, loaded from a JSON file, loaded from cache, or fetched from a supported block explorer.
165
+
166
+ >>> usdc = Contract("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", chain=1)
167
+
168
+ Function ABIs are installed as callable attributes.
169
+
170
+ >>> usdc.name()
171
+ 'USD Coin'
172
+
173
+ >>> usdc.symbol()
174
+ 'USDC'
175
+
176
+ >>> usdc.balanceOf("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
177
+ 123456789
178
+
179
+ Read-only functions perform `eth_call`. Nonpayable and payable functions build, sign, broadcast, and return a `Transaction`.
180
+
181
+ >>> tx = usdc.transfer(
182
+ ... "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
183
+ ... 1_000_000,
184
+ ... sender=acct,
185
+ ... )
186
+
187
+ >>> tx.wait()
188
+
189
+ Contract methods also expose encoding and decoding helpers.
190
+
191
+ >>> calldata = usdc.transfer.encode_input(
192
+ ... "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
193
+ ... 1_000_000,
194
+ ... )
195
+
196
+ >>> usdc.transfer.decode_input(calldata)
197
+ ('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 1000000)
198
+
199
+ ### 6. Inspect transactions
200
+
201
+ A transaction hash can be wrapped directly.
202
+
203
+ >>> tx = Transaction("0xf3063ed07203bc337636f1aa8cb521aa819478df764100950eebea00760a296c", chain=1)
204
+
205
+ Transaction properties wait for the first monitor update before returning.
206
+
207
+ >>> tx.sender
208
+ <Account 0x0D3AaC9458167352493864Af54D1CBD7F1B8fF68 watch-only>
209
+
210
+ >>> tx.receiver
211
+ <Account 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 watch-only>
212
+
213
+ >>> tx.value
214
+ 1000000000000000000
215
+
216
+ Decoded receipt events are available lazily from `tx.events`.
217
+
218
+ >>> len(tx.events)
219
+ 1
220
+
221
+ ## Tests
222
+
223
+ First, install the dev dependencies:
224
+
225
+ pip install -e ".[dev]"
226
+
227
+ To run the test suite:
228
+
229
+ pytest
230
+
231
+ ## License
232
+
233
+ This project is licensed under the MIT license.
@@ -0,0 +1,203 @@
1
+ # fastweb3-objects
2
+
3
+ High-level EVM objects built on `fastweb3`.
4
+
5
+ NOTE: This library is still in early alpha development. Prior to a `v1.0.0` (which may never come), expect breaking changes and no backward compatibility between versions.
6
+
7
+ ## Installation
8
+
9
+ You can install the latest release via `pip`:
10
+
11
+ pip install fastweb3-objects
12
+
13
+ Or clone the repository for the most up-to-date version:
14
+
15
+ git clone https://github.com/iamdefinitelyahuman/fastweb3-objects.git
16
+ cd fastweb3-objects
17
+ pip install -e .
18
+
19
+ ## Usage
20
+
21
+ The main entry points are available directly from `fw3_objects`:
22
+
23
+ >>> from fw3_objects import Account, Accounts, Chain, Contract, Transaction
24
+
25
+ ### 1. Connect to a chain
26
+
27
+ `Chain` is the canonical object for interacting with a specific EVM chain.
28
+
29
+ >>> chain = Chain(1)
30
+ >>> chain
31
+ Chain(1)
32
+
33
+ The underlying `fastweb3.Web3` client is created lazily. By default, it uses `fastweb3`'s public RPC discovery and endpoint pooling.
34
+
35
+ >>> chain.height()
36
+ 23100000
37
+
38
+ You can access blocks by number, hash, tag, or index syntax:
39
+
40
+ >>> chain.get_block("latest")
41
+ {'number': 23100000, ...}
42
+
43
+ >>> chain[-1]
44
+ {'number': 23100000, ...}
45
+
46
+ To use your own RPC endpoint, configure the chain before first use:
47
+
48
+ >>> from fw3_objects.chain import configure_chain
49
+
50
+ >>> configure_chain(1, endpoints=["http://localhost:8545"], use_public_pool=False)
51
+ >>> chain = Chain(1)
52
+
53
+ ### 2. Use a default chain context
54
+
55
+ Objects can be bound explicitly to a chain, or they can use the active default chain.
56
+
57
+ >>> mainnet = Chain(1)
58
+
59
+ >>> with mainnet.as_default():
60
+ ... vitalik = Account("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
61
+ ... vitalik.balance()
62
+ ...
63
+ 32131215082101779377
64
+
65
+ Strict mode rejects accidental access through another chain while the context is active.
66
+
67
+ >>> with mainnet.as_default(strict=True):
68
+ ... Account("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045").balance()
69
+
70
+ ### 3. Manage accounts
71
+
72
+ `Accounts` is a `fastweb3-keypass` database wrapper. With no arguments, it opens the default database, creating it first if needed.
73
+
74
+ >>> accounts = Accounts()
75
+ Create password for new Accounts database 'default': ***
76
+
77
+ >>> accounts
78
+ <Accounts unlocked>
79
+
80
+ Accounts created or imported through the database can sign transactions.
81
+
82
+ >>> acct = accounts.create_account(alias="deployer", set_as_default=True)
83
+ >>> acct
84
+ <Account 0x0D3AaC9458167352493864Af54D1CBD7F1B8fF68 signable>
85
+
86
+ You can also create watch-only account objects directly from an address.
87
+
88
+ >>> vitalik = Account("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", chain=1)
89
+ >>> vitalik
90
+ <Account 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 watch-only>
91
+
92
+ Chain-aware account helpers expose common RPC operations.
93
+
94
+ >>> vitalik.balance()
95
+ 32131215082101779377
96
+
97
+ >>> vitalik.nonce()
98
+ 1832
99
+
100
+ >>> vitalik.bytecode()
101
+ b''
102
+
103
+ ### 4. Send transactions
104
+
105
+ Signing accounts can build, sign, broadcast, and watch transactions in a single call.
106
+
107
+ >>> tx = acct.transact(
108
+ ... to="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
109
+ ... value=10**18,
110
+ ... chain=1,
111
+ ... )
112
+
113
+ The returned `Transaction` object tracks mempool, receipt, replacement, and revert state.
114
+
115
+ >>> tx.status
116
+ <TxStatus.PENDING: -1>
117
+
118
+ >>> tx.wait()
119
+ >>> tx.status
120
+ <TxStatus.CONFIRMED: 1>
121
+
122
+ >>> tx.block_number
123
+ 23100012
124
+
125
+ >>> tx.gas_used
126
+ 21000
127
+
128
+ Pending transactions can be replaced with a higher-fee transaction when the sender is available in an open `Accounts` database.
129
+
130
+ >>> replacement = tx.replace()
131
+
132
+ ### 5. Interact with contracts
133
+
134
+ `Contract` binds an address, ABI, and chain. ABI can be provided directly, loaded from a JSON file, loaded from cache, or fetched from a supported block explorer.
135
+
136
+ >>> usdc = Contract("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", chain=1)
137
+
138
+ Function ABIs are installed as callable attributes.
139
+
140
+ >>> usdc.name()
141
+ 'USD Coin'
142
+
143
+ >>> usdc.symbol()
144
+ 'USDC'
145
+
146
+ >>> usdc.balanceOf("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
147
+ 123456789
148
+
149
+ Read-only functions perform `eth_call`. Nonpayable and payable functions build, sign, broadcast, and return a `Transaction`.
150
+
151
+ >>> tx = usdc.transfer(
152
+ ... "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
153
+ ... 1_000_000,
154
+ ... sender=acct,
155
+ ... )
156
+
157
+ >>> tx.wait()
158
+
159
+ Contract methods also expose encoding and decoding helpers.
160
+
161
+ >>> calldata = usdc.transfer.encode_input(
162
+ ... "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
163
+ ... 1_000_000,
164
+ ... )
165
+
166
+ >>> usdc.transfer.decode_input(calldata)
167
+ ('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 1000000)
168
+
169
+ ### 6. Inspect transactions
170
+
171
+ A transaction hash can be wrapped directly.
172
+
173
+ >>> tx = Transaction("0xf3063ed07203bc337636f1aa8cb521aa819478df764100950eebea00760a296c", chain=1)
174
+
175
+ Transaction properties wait for the first monitor update before returning.
176
+
177
+ >>> tx.sender
178
+ <Account 0x0D3AaC9458167352493864Af54D1CBD7F1B8fF68 watch-only>
179
+
180
+ >>> tx.receiver
181
+ <Account 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 watch-only>
182
+
183
+ >>> tx.value
184
+ 1000000000000000000
185
+
186
+ Decoded receipt events are available lazily from `tx.events`.
187
+
188
+ >>> len(tx.events)
189
+ 1
190
+
191
+ ## Tests
192
+
193
+ First, install the dev dependencies:
194
+
195
+ pip install -e ".[dev]"
196
+
197
+ To run the test suite:
198
+
199
+ pytest
200
+
201
+ ## License
202
+
203
+ This project is licensed under the MIT license.
@@ -0,0 +1,63 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fastweb3-objects"
7
+ version = "0.1.0"
8
+ description = "High-level objects built on fastweb3."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "iamdefinitelyahuman" }
14
+ ]
15
+
16
+ dependencies = [
17
+ "eth-stdlib>=0.2.7,<0.3",
18
+ "fastweb3>=0.1.6,<0.2.0",
19
+ "fastweb3-keypass>=0.1.2,<0.2.0",
20
+ "platformdirs>=4.0",
21
+ "pycryptodome>=3.20",
22
+ ]
23
+
24
+ [project.optional-dependencies]
25
+ dev = [
26
+ "pytest>=8",
27
+ "pytest-cov>=5",
28
+ "ruff>=0.9",
29
+ "pre-commit>=3",
30
+ "build",
31
+ "twine",
32
+ "mkdocs>=1.6",
33
+ "mkdocs-material>=9.5",
34
+ ]
35
+ docs = [
36
+ "mkdocs>=1.6",
37
+ "mkdocs-material>=9.5",
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://github.com/iamdefinitelyahuman/fastweb3-objects"
42
+ Repository = "https://github.com/iamdefinitelyahuman/fastweb3-objects"
43
+
44
+ [tool.setuptools]
45
+ package-dir = {"" = "src"}
46
+
47
+ [tool.setuptools.packages.find]
48
+ where = ["src"]
49
+
50
+ [tool.ruff]
51
+ line-length = 100
52
+ target-version = "py312"
53
+
54
+ [tool.ruff.lint]
55
+ select = ["E", "F", "I"]
56
+
57
+ [tool.pytest.ini_options]
58
+ addopts = [
59
+ "--cov=fw3_objects",
60
+ "--cov-report=term-missing",
61
+ "--cov-report=xml",
62
+ ]
63
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+