Code Monkey home page Code Monkey logo

fiber-py's Introduction

fiber-py

Installation

With pip:

pip install git+https://github.com/chainbound/fiber-py

With Poetry:

poetry add git+https://github.com/chainbound/fiber-py

Usage

Connecting

from fiber.client import Client

client = Client('FIBER_ENDPOINT', 'YOUR_API_KEY')
try:
  client.connect()
except Exception as e:
  print('Error connecting', e)

Subscribing to transactions

The transaction stream is supported but without any filtering for now. This stream yields fiber.types.Transaction objects. All the bytes fields are encoded as hexadecimal strings.

try:
  sub = client.subscribe_new_txs()

  # Iterate over transaction stream
  for tx in sub:
    do_something(tx)
except Exception as e:
  print("error subscribing", e)

Note You can also get the RLP-encoded signed transaction with the methods tx.to_rlp_bytes() and tx.to_rlp_hex() to get the raw bytes or the hex string respectively.

Subscribing to blocks

Execution Payload Headers

This stream yields only the new block headers as fiber.types.ExecutionPayloadHeader objects. All the bytes fields are encoded as hexadecimal strings.

try:
  sub = client.subscribe_new_execution_payload_headers()

  for header in sub:
    do_something(header)
except Exception as e:
  print("error subscribing", e)

Execution Payloads

This stream yields the new blocks as full fiber.types.ExecutionPayload objects. All the bytes fields are encoded as hexadecimal strings.

try:
  sub = client.subscribe_new_execution_payloads()

  for block in sub:
    do_something(block)
except Exception as e:
  print("error subscribing", e)

Beacon Blocks

This stream yields the blocks as seen by the Ethereum consensus layer, in the form of fiber.types.BeaconBlock objects. All the bytes fields are encoded as hexadecimal strings.

Note Beacon blocks do not contain the execution payloads. To also get the execution payloads, please subscribe to the execution payload stream subscribe_new_execution_payloads() separately.

try:
  sub = client.subscribe_new_beacon_blocks()

  for block in sub:
    do_something(block)
except Exception as e:
  print("error subscribing", e)

fiber-py's People

Contributors

merklefruit avatar mempirate avatar boskeyacht avatar thedevbirb avatar

Stargazers

Francesco Mosterts avatar  avatar

Watchers

 avatar  avatar Francesco Mosterts avatar

Forkers

boskeyacht

fiber-py's Issues

Fix: installation issue

Fix required to reflect latest releases and not make the client fail.

Currently after the repo is cloned, test script fails with the following error message:

C:\Users\franc\github_local_repos\fiber_benchamark_v2\venv\Scripts\python.exe C:/Users/franc/github_local_repos/fiber_benchamark_v2/main.py Traceback (most recent call last): File "C:\Users\franc\github_local_repos\fiber_benchamark_v2\main.py", line 1, in <module> from fiber.client import Client File "C:\Users\franc\github_local_repos\fiber_benchamark_v2\venv\lib\site-packages\fiber\client.py", line 3, in <module> from fiber.proto import api_pb2_grpc File "C:\Users\franc\github_local_repos\fiber_benchamark_v2\venv\lib\site-packages\fiber\proto\api_pb2_grpc.py", line 5, in <module> import api_pb2 as api__pb2 ModuleNotFoundError: No module named 'api_pb2'

Support asyncio

fiber-py currently does not support async libraries. Therefore costumers need to run streams in separate treads. To improve UX fiber-py should support asyncio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.