{"id":18263316,"url":"https://github.com/safe-global/safe-eth-py","last_synced_at":"2025-11-28T13:05:20.226Z","repository":{"id":36967981,"uuid":"146720563","full_name":"safe-global/safe-eth-py","owner":"safe-global","description":"Safe-eth-py includes a set of libraries to work with Ethereum and relevant Ethereum projects","archived":false,"fork":false,"pushed_at":"2025-05-07T08:34:32.000Z","size":3819,"stargazers_count":180,"open_issues_count":7,"forks_count":205,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-07T09:24:35.860Z","etag":null,"topics":["ethereum","gnosis","gnosis-safe","multisig","python"],"latest_commit_sha":null,"homepage":"https://safe-eth-py.readthedocs.io/en/latest/quickstart.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/safe-global.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-30T08:35:15.000Z","updated_at":"2025-05-07T08:34:35.000Z","dependencies_parsed_at":"2023-11-13T12:48:22.131Z","dependency_job_id":"be985375-db53-4d8b-812d-6da61a3daebe","html_url":"https://github.com/safe-global/safe-eth-py","commit_stats":null,"previous_names":["gnosis/gnosis-py"],"tags_count":337,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safe-global%2Fsafe-eth-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safe-global%2Fsafe-eth-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safe-global%2Fsafe-eth-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safe-global%2Fsafe-eth-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/safe-global","download_url":"https://codeload.github.com/safe-global/safe-eth-py/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198514,"owners_count":22030965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","gnosis","gnosis-safe","multisig","python"],"created_at":"2024-11-05T11:10:45.661Z","updated_at":"2025-11-28T13:05:20.217Z","avatar_url":"https://github.com/safe-global.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Safe-eth-py (previously known as Gnosis-py)\n###########################################\n\n.. class:: no-web no-pdf\n\n|ci| |coveralls| |python| |django| |pipy| |readthedocs| |black|\n\nSafe-eth-py includes a set of libraries to work with Ethereum and relevant Ethereum projects:\n  - `EthereumClient`, a wrapper over Web3.py `Web3` client including utilities to deal with ERC20/721\n    tokens and tracing.\n  - `Safe \u003chttps://github.com/safe-global/safe-contracts\u003e`_ classes and utilities.\n  - Price oracles for `Uniswap`, `Kyber`...\n  - Django serializers, models and utils.\n\nQuick start\n-----------\n\nJust run ``pip install safe-eth-py`` or add it to your **requirements.txt**\n\nIf you want django ethereum utils (models, serializers, filters...) you need to run\n``pip install safe-eth-py[django]``\n\nIf you have issues building **coincurve** maybe\n`you are missing some libraries \u003chttps://ofek.dev/coincurve/install/#source\u003e`_\n\n\nContributing to safe-eth-py\n---------------------------\nClone the repo, then to set it up:\n\n.. code-block:: bash\n\n    python -m venv venv\n    source venv/bin/activate\n    pip install -r requirements-dev.txt\n    pre-commit install -f\n\nAdd new address for new chains\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nIf you want to add Safe Smart Account support for a new chain you must `open a new issue \u003chttps://github.com/safe-global/safe-eth-py/issues/new?assignees=\u0026labels=add-new-address\u0026projects=\u0026template=add_safe_address_new_chain.yml\u0026title=%5BNew+chain%5D%3A+%7Bchain+name%7D\u003e`_.\n\nOnce the issue is created or edited, an automatic validation will be executed and a **Pull Request** will be created if everything is ok. Finally, the Safe team will review and merge the automatic **Pull Request** generated from the issue.\n\nEthereum utils\n--------------\nsafe_eth.eth\n~~~~~~~~~~~~\n- ``class EthereumClient (ethereum_node_url: str)``: Class to connect and do operations\n  with an ethereum node. Uses web3 and raw rpc calls for things not supported in web3.\n  Only ``http/https`` urls are supported for the node url.\n\n``EthereumClient`` has some utils that improve a lot performance using Ethereum nodes, like\nthe possibility of doing ``batch_calls`` (a single request making read-only calls to multiple contracts):\n\n.. code-block:: python\n\n  from safe_eth.eth import EthereumClient\n  from safe_eth.eth.contracts import get_erc721_contract\n  ethereum_client = EthereumClient(ETHEREUM_NODE_URL)\n  erc721_contract = get_erc721_contract(self.w3, token_address)\n  name, symbol = ethereum_client.batch_call([\n                      erc721_contract.functions.name(),\n                      erc721_contract.functions.symbol(),\n                  ])\n\nIf you want to use the underlying `web3.py \u003chttps://github.com/ethereum/web3.py\u003e`_ library:\n\n.. code-block:: python\n\n  from safe_eth.eth import EthereumClient\n  ethereum_client = EthereumClient(ETHEREUM_NODE_URL)\n  ethereum_client.w3.eth.get_block(57)\n\n\nsafe_eth.eth.constants\n~~~~~~~~~~~~~~~~~~~~~~\n- ``NULL_ADDRESS (0x000...0)``: Solidity ``address(0)``.\n- ``SENTINEL_ADDRESS (0x000...1)``: Used for Safe's linked lists (modules, owners...).\n- Maximum and minimum values for `R`, `S` and `V` in ethereum signatures.\n\nsafe_eth.eth.oracles\n~~~~~~~~~~~~~~~~~~~~\nPrice oracles for Uniswap, UniswapV2, Kyber, SushiSwap, Aave, Balancer, Curve, Mooniswap, Yearn...\nExample:\n\n.. code-block:: python\n\n  from safe_eth.eth import EthereumClient\n  from safe_eth.eth.oracles import UniswapV2Oracle\n  ethereum_client = EthereumClient(ETHEREUM_NODE_URL)\n  uniswap_oracle = UniswapV2Oracle(ethereum_client)\n  gno_token_mainnet_address = '0x6810e776880C02933D47DB1b9fc05908e5386b96'\n  weth_token_mainnet_address = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'\n  price = uniswap_oracle.get_price(gno_token_mainnet_address, uniswap_oracle.weth_address)\n\n\n\nsafe_eth.eth.utils\n~~~~~~~~~~~~~~~~~~\n\nContains utils for ethereum operations:\n\n- ``mk_contract_address_2(from_: Union[str, bytes], salt: Union[str, bytes], init_code: [str, bytes]) -\u003e str``:\n  Calculates the address of a new contract created using the new CREATE2 opcode.\n\nEthereum django (REST) utils\n----------------------------\nDjango utils are available under ``safe_eth.eth.django``.\nYou can find a set of helpers for working with Ethereum using Django and Django Rest framework.\n\nIt includes:\n\n- **safe_eth.eth.django.filters**: EthereumAddressFilter.\n- **safe_eth.eth.django.models**: Model fields (Ethereum address, Ethereum big integer field).\n- **safe_eth.eth.django.serializers**: Serializer fields (Ethereum address field, hexadecimal field).\n- **safe_eth.eth.django.validators**: Ethereum related validators.\n- **safe_eth.safe.serializers**: Serializers for Safe (signature, transaction...).\n- All the tests are written using Django Test suite.\n\n\nSafe APIs\n--------------\nsafe_eth.safe.api\n~~~~~~~~~~~~~~~~~\nInteraction with the Safe Transaction Service API to manage Safes, transactions, delegates, and messages.\n\nTo use the default Transaction Service, you need an API key. You can set this API key either as an environment variable\nor pass it directly to the constructor using the `api_key` parameter. To obtain your API key, create an account on the\nSafe Developer Portal at https://developer.safe.global. Additionally, you can choose to use a custom service by setting\nthe `base_url` parameter, the API key may not be required.\n\n.. code-block:: bash\n\n export SAFE_TRANSACTION_SERVICE_API_KEY=[api-key-jwt-token-value]\n\nExample:\n\n.. code-block:: python\n\n    from safe_eth.eth import EthereumNetwork\n    from safe_eth.safe.api import TransactionServiceApi\n\n    transaction_service_api = TransactionServiceApi(EthereumNetwork.GNOSIS)\n    transactions = transaction_service_api.get_transactions(\"0xAedF684C1c41B51CbD228116e11484425d2FACB9\")\n\nContributors\n------------\n`See contributors \u003chttps://github.com/safe-global/safe-eth-py/graphs/contributors\u003e`_\n\n.. |ci| image:: https://github.com/safe-global/safe-eth-py/actions/workflows/python.yml/badge.svg\n    :alt: Github Actions CI build\n\n.. |coveralls| image:: https://coveralls.io/repos/github/safe-global/safe-eth-py/badge.svg\n    :target: https://coveralls.io/github/safe-global/safe-eth-py\n\n.. |python| image:: https://img.shields.io/badge/Python-3.13-blue.svg\n    :alt: Python 3.13\n\n.. |django| image:: https://img.shields.io/badge/Django-5-blue.svg\n    :alt: Django 5\n\n.. |pipy| image:: https://badge.fury.io/py/safe-eth-py.svg\n    :target: https://badge.fury.io/py/safe-eth-py\n    :alt: Pypi package\n\n.. |readthedocs| image:: https://readthedocs.org/projects/safe-eth-py/badge/?version=latest\n    :target: https://safe-eth-py.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Black\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafe-global%2Fsafe-eth-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsafe-global%2Fsafe-eth-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafe-global%2Fsafe-eth-py/lists"}