Web3 Config#
- class rizemind.web3.config.Web3Config(*, url: HttpUrl | None)[source]#
Bases:
BaseConfigConfiguration for Web3 blockchain connections.
Manages Web3 provider configuration including URL validation, middleware injection for Proof-of-Authority chains, and Web3 instance creation.
- url#
The HTTP provider URL for blockchain connectivity. If None, defaults to RizeNet testnet URL.
- Type:
pydantic.networks.HttpUrl | None
- classmethod coerce_url(value: Any) Any[source]#
Validates and coerces URL values to HttpUrl format.
Handles various input types and converts them to the appropriate HttpUrl format for Pydantic validation.
- Parameters:
value – The URL value to validate. Can be None, string, HttpUrl, or Url.
- Returns:
The validated HttpUrl object or None.
- Raises:
TypeError – If the value type is not supported.
ValidationError – If the URL string is invalid (raised by HttpUrl).
- static from_context(context: Context) Web3Config | None[source]#
Creates a Web3Config instance from a Flower context.
Extracts Web3 configuration from the provided Flower context state and constructs a Web3Config instance if the configuration exists.
- Parameters:
context – The Flower context containing configuration state.
- Returns:
A Web3Config instance if configuration is found in the context, otherwise None.
- get_web3(*, web3_factory=<class 'web3.main.Web3'>) Web3[source]#
Creates a configured Web3 instance.
Initializes a Web3 instance with the configured HTTP provider and automatically injects Proof-of-Authority middleware for supported chains.
- Parameters:
web3_factory – Factory function for creating Web3 instances. Defaults to the standard Web3 constructor.
- Returns:
A configured Web3 instance ready for blockchain interaction.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- url: HttpUrl | None#