Skip to main content

Python SDK for Ethereum Attestation Service (EAS)

Project description

Ethereum Attestation Service (EAS) SDK

Overview

The EAS SDK is a Python library for seamlessly interacting with the Ethereum Attestation Service (EAS), enabling developers to create, manage, and verify on-chain and off-chain attestations across multiple blockchain networks.

Features

  • 🌐 Multi-chain support (Ethereum, Base, Sepolia, and more)
  • 🔒 Secure environment and input validation
  • 💡 Easy-to-use methods for creating attestations
  • 📝 On-chain and off-chain attestation support
  • 🚀 Batch attestation and revocation capabilities
  • 🕒 Flexible timestamping functionality
  • 🔄 Typed attestation data conversion from GraphQL to protobuf

Installation

Install the EAS SDK using pip:

pip install eas-sdk

Quick Start

Basic Initialization

from EAS import EAS

# Initialize EAS for a specific chain
eas = EAS.from_chain(
    chain='base-sepolia',
    private_key='YOUR_PRIVATE_KEY',
    from_account='YOUR_ETHEREUM_ADDRESS'
)

Creating an Attestation

# Register a schema first
schema_uid = eas.register_schema(
    schema="uint256 id,string name",
    network_name="base-sepolia"
)

# Create an attestation
result = eas.attest(
    schema_uid=schema_uid,
    recipient='0x1234...',
    data_values={
        'types': ['uint256', 'string'],
        'values': [42, 'John Doe']
    }
)

print(f"Attestation created: {result.tx_hash}")

Off-Chain Attestation

# Create an off-chain attestation
offchain_attestation = eas.attest_offchain({
    'schema': schema_uid,
    'recipient': '0x1234...',
    'data': b'Offchain data'
})

Batch Operations

# Batch attestation
eas.multi_attest([
    {
        'schema_uid': schema_uid,
        'attestations': [
            {
                'recipient': '0x1234...',
                'data': b'First attestation'
            },
            {
                'recipient': '0x5678...',
                'data': b'Second attestation'
            }
        ]
    }
])

# Batch revocation
eas.multi_revoke([
    {'uid': '0x...first_attestation_uid'},
    {'uid': '0x...second_attestation_uid'}
])

Configuration

Environment Variables

You can also configure EAS using environment variables:

export EAS_CHAIN=base-sepolia
export EAS_PRIVATE_KEY=your_private_key
export EAS_FROM_ACCOUNT=your_ethereum_address

Then initialize EAS without parameters:

eas = EAS.from_environment()

Advanced Configuration

Custom Network Support

# Use a custom RPC endpoint and contract address
eas = EAS.from_chain(
    chain='custom_network',
    private_key='your_private_key',
    from_account='your_address',
    rpc_url='https://custom-rpc.network',
    contract_address='0x..custom_contract_address'
)

Supported Chains

# List all supported chains
print(EAS.list_supported_chains())

# Get configuration for a specific chain
base_config = EAS.get_network_config('base')

Security Features

  • Input validation for all parameters
  • Secure environment variable handling
  • Comprehensive error logging
  • Contract address validation

Attestation Data Conversion

Convert EAS attestation data from GraphQL responses to strongly-typed protobuf messages:

from src.main.EAS.attestation_converter import AttestationConverter, from_graphql_json

# Convert GraphQL decodedDataJson to typed objects
converter = AttestationConverter(
    lambda data: YourProtobufType(
        domain=data.get("domain", ""),
        identifier=data.get("identifier", "")
    )
)

graphql_data = from_graphql_json('your_decoded_data_json')
typed_result = converter.convert(graphql_data)

For detailed usage examples and advanced patterns, see Attestation Converter Documentation.

Error Handling

The SDK provides detailed exceptions:

  • EASValidationError: Input validation failures
  • EASTransactionError: Blockchain interaction problems
  • SecurityError: Security-related issues

Performance Considerations

  • Uses gas estimation with a 20% buffer
  • Supports batch operations for gas efficiency
  • Provides fallback mechanisms for gas estimation

Contribution

Contributions are welcome! Please read our Contribution Guidelines before submitting a pull request.

License

[Insert your project's license here]

Support

For issues, questions, or support, please file an issue on our GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eas_sdk-0.1.4.tar.gz (63.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eas_sdk-0.1.4-py3-none-any.whl (65.3 kB view details)

Uploaded Python 3

File details

Details for the file eas_sdk-0.1.4.tar.gz.

File metadata

  • Download URL: eas_sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 63.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for eas_sdk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 bbe82edda47658c4b288ae337f8f041f1aad56310156c237112c26586c1db176
MD5 9d30c5027af887582fa2aea4101948f8
BLAKE2b-256 7bc489b9ceba3c64fb3c85f6b3ec80f1d07b3c796bfe833629128e9bb62a5c3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for eas_sdk-0.1.4.tar.gz:

Publisher: publish.yml on cyberstorm-dev/eas-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eas_sdk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: eas_sdk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 65.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for eas_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bc2e71bd69660443f281d10f2013606b2f8c8c81e0e21fa55360964c156e8277
MD5 47e636267ab65ef6587123742bda2d5c
BLAKE2b-256 0e9a9181feafb36ff90b206c3c6e621eb705837cd8ae377593872d204bb9ba8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for eas_sdk-0.1.4-py3-none-any.whl:

Publisher: publish.yml on cyberstorm-dev/eas-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page