web3-account


Nameweb3-account JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/langeth123/Web3Account
SummaryThe simplest way to use Web3 features
upload_time2023-08-12 09:00:07
maintainer
docs_urlNone
authorlang123
requires_python
licenseApache License, Version 2.0, see LICENSE file
keywords
VCS
bugtrack_url
requirements eth_account loguru requests web3
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Web3Account

**Web3Account** - this module is a Python client library as the simplest way to use Web3 features

## Installation

Install the current version with [PyPI](https://pypi.org/project/web3-account/):

```bash
pip install web3-account
```

## Usage

You can make trasfers like this

```python
from web3_account import *

account = Web3Account(
    "", # your secret key
    "avalanche",
    after_tx_sleeping=False  # after_tx_sleeping - sleep random timing after submitted tx
)

tx_status = account.send_money("0x54C32309b67e72bD44899e46EC630d14Eb96125f", 0.001)

logs.info(f'Tx status: {tx_status}. If it is True - tx complited, else: failed')
```
On Lib already includes web3 nodes for all popular chains (using [Ankr](https://www.ankr.com/rpc/)), so, you can change it if it needed
```python
links = {
    "polygon" : ['http://my_custom_node.com']
}

account = Web3Account(
    "", # your secret key
    "polygon", # set up work net_name
    after_tx_sleeping=False,  # after_tx_sleeping - sleep random timing after submitted tx
    nodes=links # our custom links
)

```

## Example of swaps

Lib also include ```swap```* function from 1inch api url

```python
from web3_account import *


account = Web3Account(
    "", # your secret key
    "polygon",
    after_tx_sleeping=False  # after_tx_sleeping - sleep random timing after submitted tx
)

matic_balance = account.get_native_balance()
human_readable_balance = Web3.from_wei(matic_balance, 'ether')

logs.info(f'Balance: {human_readable_balance}')            # print without file logging
account.logger.info(f'Balance: {human_readable_balance}')  # print with file logging

token_out = "0x2297aEbD383787A160DD0d9F71508148769342E3" # btc address


swap_response = account.swap(
    "eth",
    token_out,
    round(matic_balance * 0.1),
    increase_gas_price=3 # increase_gas_price coef of increasing gwei price (for polygon recomended)
) # will buy btc with $matic for 10% of total balance


btcb_balance, human_readable_btb_balance = account.get_balance(token_out)
account.logger.info(f'Have: {human_readable_btb_balance} $btc')

swap_response = account.swap(
    token_out,
    "eth",
    btcb_balance,
    increase_gas_price=3 # increase_gas_price coef of increasing gwei price (for polygon recomended)
) # will sell btc to matic on ALL balance of btc

account.logger.info(f'Swap response: {swap_response}')

```

## Contributing

Bug reports and/or pull requests are welcome

## License

The module is available as open source under the terms of the [Apache License, Version 2.0](https://opensource.org/licenses/Apache-2.0)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/langeth123/Web3Account",
    "name": "web3-account",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "lang123",
    "author_email": "dima.lang3103@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d3/73/0bc213a831dbe309a5e423f238968f5346665dc21fde0c3ea0ca0529eb57/web3_account-1.0.1.tar.gz",
    "platform": null,
    "description": "# Web3Account\r\n\r\n**Web3Account** - this module is a Python client library as the simplest way to use Web3 features\r\n\r\n## Installation\r\n\r\nInstall the current version with [PyPI](https://pypi.org/project/web3-account/):\r\n\r\n```bash\r\npip install web3-account\r\n```\r\n\r\n## Usage\r\n\r\nYou can make trasfers like this\r\n\r\n```python\r\nfrom web3_account import *\r\n\r\naccount = Web3Account(\r\n    \"\", # your secret key\r\n    \"avalanche\",\r\n    after_tx_sleeping=False  # after_tx_sleeping - sleep random timing after submitted tx\r\n)\r\n\r\ntx_status = account.send_money(\"0x54C32309b67e72bD44899e46EC630d14Eb96125f\", 0.001)\r\n\r\nlogs.info(f'Tx status: {tx_status}. If it is True - tx complited, else: failed')\r\n```\r\nOn Lib already includes web3 nodes for all popular chains (using [Ankr](https://www.ankr.com/rpc/)), so, you can change it if it needed\r\n```python\r\nlinks = {\r\n    \"polygon\" : ['http://my_custom_node.com']\r\n}\r\n\r\naccount = Web3Account(\r\n    \"\", # your secret key\r\n    \"polygon\", # set up work net_name\r\n    after_tx_sleeping=False,  # after_tx_sleeping - sleep random timing after submitted tx\r\n    nodes=links # our custom links\r\n)\r\n\r\n```\r\n\r\n## Example of swaps\r\n\r\nLib also include ```swap```* function from 1inch api url\r\n\r\n```python\r\nfrom web3_account import *\r\n\r\n\r\naccount = Web3Account(\r\n    \"\", # your secret key\r\n    \"polygon\",\r\n    after_tx_sleeping=False  # after_tx_sleeping - sleep random timing after submitted tx\r\n)\r\n\r\nmatic_balance = account.get_native_balance()\r\nhuman_readable_balance = Web3.from_wei(matic_balance, 'ether')\r\n\r\nlogs.info(f'Balance: {human_readable_balance}')            # print without file logging\r\naccount.logger.info(f'Balance: {human_readable_balance}')  # print with file logging\r\n\r\ntoken_out = \"0x2297aEbD383787A160DD0d9F71508148769342E3\" # btc address\r\n\r\n\r\nswap_response = account.swap(\r\n    \"eth\",\r\n    token_out,\r\n    round(matic_balance * 0.1),\r\n    increase_gas_price=3 # increase_gas_price coef of increasing gwei price (for polygon recomended)\r\n) # will buy btc with $matic for 10% of total balance\r\n\r\n\r\nbtcb_balance, human_readable_btb_balance = account.get_balance(token_out)\r\naccount.logger.info(f'Have: {human_readable_btb_balance} $btc')\r\n\r\nswap_response = account.swap(\r\n    token_out,\r\n    \"eth\",\r\n    btcb_balance,\r\n    increase_gas_price=3 # increase_gas_price coef of increasing gwei price (for polygon recomended)\r\n) # will sell btc to matic on ALL balance of btc\r\n\r\naccount.logger.info(f'Swap response: {swap_response}')\r\n\r\n```\r\n\r\n## Contributing\r\n\r\nBug reports and/or pull requests are welcome\r\n\r\n## License\r\n\r\nThe module is available as open source under the terms of the [Apache License, Version 2.0](https://opensource.org/licenses/Apache-2.0)\r\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0, see LICENSE file",
    "summary": "The simplest way to use Web3 features",
    "version": "1.0.1",
    "project_urls": {
        "Download": "https://github.com/langeth123/Web3Account/archive/v1.0.1.zip",
        "Homepage": "https://github.com/langeth123/Web3Account"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d3730bc213a831dbe309a5e423f238968f5346665dc21fde0c3ea0ca0529eb57",
                "md5": "9ef805d96d1ef7de0cacff475ab600af",
                "sha256": "7415c53bf3b76683c001a17228bbe40a377c5eecdfc4d53f671e1e485ba82668"
            },
            "downloads": -1,
            "filename": "web3_account-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9ef805d96d1ef7de0cacff475ab600af",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8065,
            "upload_time": "2023-08-12T09:00:07",
            "upload_time_iso_8601": "2023-08-12T09:00:07.275469Z",
            "url": "https://files.pythonhosted.org/packages/d3/73/0bc213a831dbe309a5e423f238968f5346665dc21fde0c3ea0ca0529eb57/web3_account-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-12 09:00:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "langeth123",
    "github_project": "Web3Account",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "eth_account",
            "specs": [
                [
                    "==",
                    "0.9.0"
                ]
            ]
        },
        {
            "name": "loguru",
            "specs": [
                [
                    "==",
                    "0.7.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "web3",
            "specs": [
                [
                    "==",
                    "6.6.1"
                ]
            ]
        }
    ],
    "lcname": "web3-account"
}
        
Elapsed time: 0.25088s