Python Builder Signing SDK
The Python Builder Signing SDK facilitates the creation and signing of builder bids and bundles for blockchain applications, specifically in the context of MEV (Maximal Extractable Value) builders. It handles the cryptographic signing processes using `eth-account` and `eip712`. The current version is 0.0.2, and it appears to follow an infrequent release cadence, typical for specialized blockchain tools.
Warnings
- breaking The library is in a very early stage (version 0.0.2). The API and internal mechanisms are subject to rapid change, potentially introducing breaking changes even between minor patch versions. Users should pin exact versions and review release notes diligently.
- gotcha Directly embedding private keys in source code or insecurely managing them is a severe security risk. This library requires a private key for signing, which must be handled with extreme care.
- gotcha The library relies on `web3` and `eth-account` as dependencies. Major version upgrades of these libraries (e.g., `web3` v5 to v6) have introduced significant breaking changes in the past, which could indirectly affect `py-builder-signing-sdk`'s behavior or require specific versions.
Install
-
pip install py-builder-signing-sdk
Imports
- Builder
from builder_signing_sdk.builder import Builder
- Account
from eth_account import Account
- LocalAccount
from eth_account.signers.local import LocalAccount
Quickstart
import os
from builder_signing_sdk.builder import Builder
from eth_account import Account
# WARNING: In a real application, retrieve your private key securely, e.g., from environment variables.
# DO NOT hardcode private keys in production code.
# This is a dummy private key for demonstration purposes ONLY.
private_key_env = os.environ.get('BUILDER_PRIVATE_KEY', '0x1111111111111111111111111111111111111111111111111111111111111111')
if private_key_env == '0x1111111111111111111111111111111111111111111111111111111111111111':
print("WARNING: Using a dummy private key. Set BUILDER_PRIVATE_KEY environment variable for real usage.")
# Initialize an Ethereum account from the private key
account = Account.from_key(private_key_env)
# Define your builder's name
builder_name = os.environ.get('BUILDER_NAME', 'my-test-builder')
# Initialize the Builder SDK
builder = Builder(builder_name, account)
print(f"Initialized Builder SDK for '{builder_name}' with Ethereum address: {account.address}")
print("You can now use 'builder.sign_bid()' or 'builder.sign_bundle()' to sign MEV payloads.")
# Example of how you would call sign_bid (requires valid data, commented out to keep runnable):
# signed_bid_id = builder.sign_bid(
# gas_limit=21000,
# gas_price=10**10,
# base_fee_per_gas=10**10,
# builder_eth_balance_delta=0,
# builder_eth_balance_after=0,
# block_number=12345678,
# tx_hash="0x" + "0"*64,
# tx_eth_value=0,
# sender_address=account.address,
# destination_address="0x" + "0"*40,
# mev_gas_price=0
# )
# print(f"Signed dummy bid ID: {signed_bid_id}")