+
Skip to content

armorwallet/permissionless.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

permissionless.py

A Python library for ERC-4337 smart accounts. This is a Python implementation of the permissionless.js library.

Features

  • 🔑 Smart account abstraction using ERC-4337
  • 🧩 Modular design for different account implementations
  • 🚀 Simple and intuitive API
  • ⚡ Async-first design with httpx
  • 🔄 1:1 parity with permissionless.js API

Installation

pip install permissionless

Quick Start

import asyncio
import os
from eth_account import Account as EthAccount
import httpx

from permissionless import SmartAccountClient
from permissionless.accounts import to_simple_smart_account
from permissionless.types import Address, EntryPoint
from permissionless.utils import parse_ether


async def main():
    # Create owner account
    private_key = os.environ.get("PRIVATE_KEY")
    owner = EthAccount.from_key(private_key)
    
    # Create simple smart account
    entry_point = EntryPoint.v0_6_0()  # Use EntryPoint v0.6.0
    
    simple_account = await to_simple_smart_account(
        owner={
            "address": owner.address,
            "private_key": private_key
        },
        entry_point=entry_point.address
    )
    
    # Create smart account client (using Sepolia testnet)
    client = SmartAccountClient(
        bundler_transport=httpx.AsyncClient(
            base_url="https://api.pimlico.io/v1/sepolia/rpc?apikey=YOUR_API_KEY_HERE"
        ),
        account=simple_account,
        chain_id=11155111  # Sepolia chain ID
    )
    
    # Send a transaction
    recipient = "0x8f7b17a74569B62D1Bd6e50F5Db51Dd4F1C2413E"
    amount = parse_ether("0.01")  # 0.01 ETH
    
    user_op_hash = await client.send_transaction(
        to=recipient,
        value=amount,
        data="0x"
    )
    print(f"User operation submitted with hash: {user_op_hash}")
    
    # Wait for the transaction to be included in a block
    receipt = await client.wait_for_user_operation_receipt(user_op_hash)
    print(f"Transaction included in block: {receipt.receipt.transaction_hash}")
    
    # Close the client
    await client.close()


if __name__ == "__main__":
    asyncio.run(main())

Documentation

For full documentation, see the permissionless.py documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Development Status

This library is in active development and API may change. Please report any bugs or feature requests in the issues.

Credits

This project is a port of the excellent permissionless.js library to Python.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载