solver-multiRPC


Namesolver-multiRPC JSON
Version 2.0.2 PyPI version JSON
download
home_pagehttps://github.com/SYMM-IO/solver-multiRPC.git
SummaryUse multiple rpc for reliability
upload_time2024-04-22 08:22:02
maintainerNone
docs_urlNone
authorrorschach
requires_python>=3.7.2
licenseNone
keywords multirpc solver
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # solver-MultiRpc: Reliable Ethereum Interactions with Multiple RPCs

`solver-MultiRpc` is a Python package designed to enhance the reliability of Ethereum smart contract interactions by utilizing multiple RPC (Remote Procedure Call) endpoints. If one RPC fails, the system can fall back to another, ensuring a higher success rate for your operations.

## Features

- **Multiple RPC Support**: Seamlessly switch between different RPCs to ensure uninterrupted interactions.
- **Gas Management**: Fetch gas prices from multiple sources to ensure transactions are sent with an appropriate fee.
- **Robust Error Handling**: Designed to handle failures gracefully, increasing the reliability of your applications.
- **Easy-to-use API**: Interact with Ethereum smart contracts using a simple and intuitive API.


## Installation

Install `solver-MultiRpc` using pip:

```bash
pip install solver-multiRPC
```

## Quick Start

Here's a quick example to get you started:

```python
import asyncio
import json
from multirpc import MultiRpc
from src.multirpc.utils import NestedDict


async def main():
    rpcs = NestedDict({
        "view": {
            1: ['https://1rpc.io/ftm', 'https://rpcapi.fantom.network', 'https://rpc3.fantom.network'],
            2: ['https://rpc.fantom.network', 'https://rpc2.fantom.network', ],
            3: ['https://rpc.ankr.com/fantom'],
        },
        "transaction": {
            1: ['https://1rpc.io/ftm', 'https://rpcapi.fantom.network', 'https://rpc3.fantom.network'],
            2: ['https://rpc.fantom.network', 'https://rpc2.fantom.network', ],
            3: ['https://rpc.ankr.com/fantom'],
        }
    })
    with open("abi.json", "r") as f:
        abi = json.load(f)
    multi_rpc = MultiRpc(rpcs, 'YOUR_CONTRACT_ADDRESS', contract_abi=abi, enable_gas_estimation=True)

    await multi_rpc.setup()
    multi_rpc.set_account("YOUR_PUBLIC_ADDRESS", "YOUR_PRIVATE_KEY")
    result = await multi_rpc.functions.YOUR_FUNCTION().call()
    print(result)

asyncio.run(main())
```

Replace placeholders like `YOUR_CONTRACT_ADDRESS`, `YOUR_PUBLIC_ADDRESS`, `YOUR_PRIVATE_KEY`, and `YOUR_FUNCTION` with appropriate values.

## Documentation

### Initialization

Initialize the `MultiRpc` class with your RPC URLs, contract address, and contract ABI:

```python
multi_rpc = MultiRpc(rpcs, contract_address='YOUR_CONTRACT_ADDRESS', contract_abi=abi)
```

### Setup

Before making any calls, set up the connection to the provided RPCs:

```python
await multi_rpc.setup()
```

### Setting Account

Set the Ethereum account details (address and private key) for sending transactions:

```python
multi_rpc.set_account("YOUR_PUBLIC_ADDRESS", "YOUR_PRIVATE_KEY")
```

### Calling Contract Functions

Call a function from your contract:

```python
result = await multi_rpc.functions.YOUR_FUNCTION().call()
```

## Contributing

Contributions are welcome! Please open an issue or submit a pull request on our GitHub repository.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SYMM-IO/solver-multiRPC.git",
    "name": "solver-multiRPC",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7.2",
    "maintainer_email": null,
    "keywords": "multiRPC solver",
    "author": "rorschach",
    "author_email": "rorschach45001@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3f/fb/a5b17ba39fa66f9854f788fa376bac8617b9a7970d416a852f0b86a4cc1c/solver-multiRPC-2.0.2.tar.gz",
    "platform": null,
    "description": "# solver-MultiRpc: Reliable Ethereum Interactions with Multiple RPCs\n\n`solver-MultiRpc` is a Python package designed to enhance the reliability of Ethereum smart contract interactions by utilizing multiple RPC (Remote Procedure Call) endpoints. If one RPC fails, the system can fall back to another, ensuring a higher success rate for your operations.\n\n## Features\n\n- **Multiple RPC Support**: Seamlessly switch between different RPCs to ensure uninterrupted interactions.\n- **Gas Management**: Fetch gas prices from multiple sources to ensure transactions are sent with an appropriate fee.\n- **Robust Error Handling**: Designed to handle failures gracefully, increasing the reliability of your applications.\n- **Easy-to-use API**: Interact with Ethereum smart contracts using a simple and intuitive API.\n\n\n## Installation\n\nInstall `solver-MultiRpc` using pip:\n\n```bash\npip install solver-multiRPC\n```\n\n## Quick Start\n\nHere's a quick example to get you started:\n\n```python\nimport asyncio\nimport json\nfrom multirpc import MultiRpc\nfrom src.multirpc.utils import NestedDict\n\n\nasync def main():\n    rpcs = NestedDict({\n        \"view\": {\n            1: ['https://1rpc.io/ftm', 'https://rpcapi.fantom.network', 'https://rpc3.fantom.network'],\n            2: ['https://rpc.fantom.network', 'https://rpc2.fantom.network', ],\n            3: ['https://rpc.ankr.com/fantom'],\n        },\n        \"transaction\": {\n            1: ['https://1rpc.io/ftm', 'https://rpcapi.fantom.network', 'https://rpc3.fantom.network'],\n            2: ['https://rpc.fantom.network', 'https://rpc2.fantom.network', ],\n            3: ['https://rpc.ankr.com/fantom'],\n        }\n    })\n    with open(\"abi.json\", \"r\") as f:\n        abi = json.load(f)\n    multi_rpc = MultiRpc(rpcs, 'YOUR_CONTRACT_ADDRESS', contract_abi=abi, enable_gas_estimation=True)\n\n    await multi_rpc.setup()\n    multi_rpc.set_account(\"YOUR_PUBLIC_ADDRESS\", \"YOUR_PRIVATE_KEY\")\n    result = await multi_rpc.functions.YOUR_FUNCTION().call()\n    print(result)\n\nasyncio.run(main())\n```\n\nReplace placeholders like `YOUR_CONTRACT_ADDRESS`, `YOUR_PUBLIC_ADDRESS`, `YOUR_PRIVATE_KEY`, and `YOUR_FUNCTION` with appropriate values.\n\n## Documentation\n\n### Initialization\n\nInitialize the `MultiRpc` class with your RPC URLs, contract address, and contract ABI:\n\n```python\nmulti_rpc = MultiRpc(rpcs, contract_address='YOUR_CONTRACT_ADDRESS', contract_abi=abi)\n```\n\n### Setup\n\nBefore making any calls, set up the connection to the provided RPCs:\n\n```python\nawait multi_rpc.setup()\n```\n\n### Setting Account\n\nSet the Ethereum account details (address and private key) for sending transactions:\n\n```python\nmulti_rpc.set_account(\"YOUR_PUBLIC_ADDRESS\", \"YOUR_PRIVATE_KEY\")\n```\n\n### Calling Contract Functions\n\nCall a function from your contract:\n\n```python\nresult = await multi_rpc.functions.YOUR_FUNCTION().call()\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on our GitHub repository.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Use multiple rpc for reliability",
    "version": "2.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/SYMM-IO/solver-multiRPC",
        "Homepage": "https://github.com/SYMM-IO/solver-multiRPC.git"
    },
    "split_keywords": [
        "multirpc",
        "solver"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ffba5b17ba39fa66f9854f788fa376bac8617b9a7970d416a852f0b86a4cc1c",
                "md5": "0c6e8ed483ddb2e891b84d80122f7545",
                "sha256": "1699eba2306293ecc14ef4ed687390c847b39350ee288014ea154f422b1bd8b0"
            },
            "downloads": -1,
            "filename": "solver-multiRPC-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0c6e8ed483ddb2e891b84d80122f7545",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.2",
            "size": 16741,
            "upload_time": "2024-04-22T08:22:02",
            "upload_time_iso_8601": "2024-04-22T08:22:02.282688Z",
            "url": "https://files.pythonhosted.org/packages/3f/fb/a5b17ba39fa66f9854f788fa376bac8617b9a7970d416a852f0b86a4cc1c/solver-multiRPC-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-22 08:22:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SYMM-IO",
    "github_project": "solver-multiRPC",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "solver-multirpc"
}
        
Elapsed time: 0.23770s