abinator-0.0.6
توضیحات
Python data class-like wrapper for solidity abi specification
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | abinator-0.0.6 |
| نام | abinator |
| نسخه کتابخانه | 0.0.6 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Dmitry Andreev <deal.d@me.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/abinator/ |
| مجوز | MIT License Copyright (c) [year] [fullname] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
# Abinator
Define ABI for your smart contract with dataclass-like style.
#### Quick example
Define your abi as `Abi` child. `Abi.to_abi()` returns abi as json, so you can use it with `web3py` and `web3-premium`.
```python
from abinator import Abi, uint256, uint8
class ERC20Fragment(Abi):
decimals: uint8
@view
def balanceOf(account: address) -> uint256:
...
ERC20Fragment.to_abi() # returns json with abi
```
<hr/>
## Documentation
### State mutability
You can use `view`, `pure`, `payable` decoratos for state mutabilty.
```python
from abinator import Abi, uint256
class Contract(Abi):
@view
def balanceOf(account: address) -> uint256:
...
@payable
def deposit():
...
@pure
def safe_add(a: uint256, b: uint256) -> uint256:
...
```
### Events
Define events with child class of `Event` inside your abi class.
You can use `indexed` decorator for topics.
```python
from abinator import Abi, Event, address, uint256, indexed
class ERC20Fragment(Abi):
class Transfer(Event):
from_: indexed(address)
to: indexed(address)
value: uint256
```
Also there is `anonymous` for event class:
```python
from abinator import Abi, Event, anonymous, uint256
class Contract(Abi):
@anonymous
class AnonymousEvent(Event):
value: uint256
```
### Structs and tuple
Define structs with child class of `Struct` inside your abi class.
```python
from abinator import Abi, Struct, payable, address, uint24, int24, uint256
class NonfungiblePositionManager(Abi):
class MintParams(Struct):
token0: address
token1: address
fee: uint24
tickLower: int24
tickUpper: int24
amount0Desired: uint256
amount1Desired: uint256
amount0Min: uint256
amount1Min: uint256
recipient: address
deadline: uint256
@payable
def mint(params: MintParams) -> tuple[uint256, uint128, uint256, uint256]:
...
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9 | Python |
نحوه نصب
نصب پکیج whl abinator-0.0.6:
pip install abinator-0.0.6.whl
نصب پکیج tar.gz abinator-0.0.6:
pip install abinator-0.0.6.tar.gz