Skip to main content

Python SDK for PureChain EVM network - Zero gas cost blockchain development

Project description

PureChain Python Library 🐍

Python Version License: MIT Version

Zero Gas Cost Blockchain Development in Python

Python SDK for PureChain EVM network with completely FREE transactions. Deploy contracts, send tokens, and interact with smart contracts without any gas fees!

🚀 Quick Start

pip install purechainlib
import asyncio
from purechainlib import PureChain

async def main():
    # Initialize PureChain
    pc = PureChain('testnet')
    
    # Connect your wallet
    pc.connect('your_private_key_here')
    
    # Check balance (FREE!)
    balance = await pc.balance()
    print(f"Balance: {balance} PURE")
    
    # Deploy a contract (FREE!)
    contract_source = """
    pragma solidity ^0.8.19;
    contract Hello {
        string public message = "Hello PureChain!";
        function setMessage(string memory _msg) public {
            message = _msg;
        }
    }
    """
    
    factory = await pc.contract(contract_source)
    contract = await factory.deploy()  # No gas fees!
    print(f"Contract deployed: {contract.address}")

asyncio.run(main())

✨ Features

  • 🆓 Zero Gas Costs - All operations are completely FREE
  • Easy to Use - Simple, intuitive API
  • 🔗 Full EVM Support - Deploy any Solidity contract
  • 🐍 Pythonic - Clean, readable Python code
  • 🔐 Secure - Industry-standard cryptography
  • 📦 Complete - Account management, compilation, deployment

📚 API Reference

Initialization

from purechainlib import PureChain

# Connect to testnet (default)
pc = PureChain('testnet')

# Or mainnet
pc = PureChain('mainnet')

# Connect with private key immediately
pc = PureChain('testnet', 'your_private_key')

Account Management

# Connect wallet
pc.connect('your_private_key_without_0x_prefix')

# Create new account
account = pc.account()
print(f"Address: {account['address']}")
print(f"Private Key: {account['privateKey']}")

# Check balance
balance = await pc.balance()  # Your balance
balance = await pc.balance('0x...address')  # Specific address

Contract Operations

# Deploy contract from source
contract_source = """
pragma solidity ^0.8.19;
contract Token {
    mapping(address => uint256) public balances;
    
    function mint(uint256 amount) public {
        balances[msg.sender] += amount;
    }
}
"""

# Compile and deploy (FREE!)
factory = await pc.contract(contract_source)
contract = await factory.deploy()

# Read from contract (FREE!)
balance = await pc.call(contract, 'balances', user_address)

# Write to contract (FREE!)
await pc.execute(contract, 'mint', 1000)

Transactions

# Send PURE tokens (FREE!)
await pc.send('0x...recipient_address', '10.5')

# Send with transaction object
await pc.send({
    'to': '0x...address',
    'value': '1.0',
    'data': '0x...'  # Optional contract data
})

Blockchain Information

# Get latest block
block = await pc.block()
print(f"Block #{block['number']}")

# Get transaction info
tx = await pc.transaction('0x...transaction_hash')

# Network status
status = await pc.status()
print(f"Chain ID: {status['chainId']}")
print(f"Gas Price: {status['gasPrice']}") # Always 0!

# Gas price (always returns 0)
gas_price = await pc.gasPrice()

Pythonic Shortcuts

# Quick balance check
balance = await pc.bal()

# Address information
info = await pc.address()
print(f"Balance: {info['balance']}")
print(f"Is Contract: {info['isContract']}")

# Check if address is a contract
is_contract = await pc.isContract('0x...address')

📝 Complete Examples

Deploy and Interact with Token Contract

import asyncio
from purechainlib import PureChain

async def token_example():
    pc = PureChain('testnet')
    pc.connect('your_private_key')
    
    # Token contract
    token_source = """
    pragma solidity ^0.8.19;
    
    contract SimpleToken {
        mapping(address => uint256) public balances;
        uint256 public totalSupply;
        string public name = "PureToken";
        
        function mint(address to, uint256 amount) public {
            balances[to] += amount;
            totalSupply += amount;
        }
        
        function transfer(address to, uint256 amount) public {
            require(balances[msg.sender] >= amount);
            balances[msg.sender] -= amount;
            balances[to] += amount;
        }
    }
    """
    
    # Deploy token (FREE!)
    factory = await pc.contract(token_source)
    token = await factory.deploy()
    print(f"Token deployed at: {token.address}")
    
    # Mint tokens (FREE!)
    await pc.execute(token, 'mint', pc.signer.address, 1000000)
    
    # Check balance (FREE!)
    balance = await pc.call(token, 'balances', pc.signer.address)
    print(f"Token balance: {balance}")
    
    # Transfer tokens (FREE!)
    recipient = "0xc8bfbC0C75C0111f7cAdB1DF4E0BC3bC45078f9d"
    await pc.execute(token, 'transfer', recipient, 100)
    print("Tokens transferred!")

asyncio.run(token_example())

Create and Fund Multiple Accounts

import asyncio
from purechainlib import PureChain

async def multi_account_example():
    pc = PureChain('testnet')
    pc.connect('your_private_key')
    
    # Create 3 new accounts
    accounts = []
    for i in range(3):
        account = pc.account()
        accounts.append(account)
        print(f"Account {i+1}: {account['address']}")
    
    # Fund each account (FREE transactions!)
    for i, account in enumerate(accounts):
        await pc.send(account['address'], f"{i+1}.0")  # Send 1, 2, 3 PURE
        print(f"Sent {i+1} PURE to account {i+1}")
    
    # Check all balances
    for i, account in enumerate(accounts):
        balance = await pc.balance(account['address'])
        print(f"Account {i+1} balance: {balance} PURE")

asyncio.run(multi_account_example())

Contract Event Monitoring

import asyncio
from purechainlib import PureChain

async def event_example():
    pc = PureChain('testnet')
    pc.connect('your_private_key')
    
    # Contract with events
    contract_source = """
    pragma solidity ^0.8.19;
    
    contract EventExample {
        event MessageSet(address indexed user, string message);
        
        string public message;
        
        function setMessage(string memory _message) public {
            message = _message;
            emit MessageSet(msg.sender, _message);
        }
    }
    """
    
    # Deploy and interact
    factory = await pc.contract(contract_source)
    contract = await factory.deploy()
    
    # Set message (creates event)
    await pc.execute(contract, 'setMessage', "Hello Events!")
    
    # Get events from last 10 blocks
    events = await pc.events(contract.address, 10)
    print(f"Found {len(events)} events")

asyncio.run(event_example())

🌐 Network Information

Network RPC URL Chain ID Gas Price
Testnet https://purechainnode.com:8547 900520900520 0 (FREE!)
Mainnet https://purechainnode.com:8547 900520900520 0 (FREE!)

❓ FAQ

Q: Are transactions really free?
A: Yes! PureChain has zero gas costs. All operations cost 0 PURE.

Q: Can I deploy any Solidity contract?
A: Yes! PureChain is fully EVM compatible.

Q: How do I get PURE tokens?
A: Contact the PureChain team or use the testnet faucet.

Q: Is this compatible with Web3?
A: Yes! Built on Web3.py with PureChain-specific optimizations.

🔗 Links

📄 License

MIT License - Free to use in any project!


Zero Gas. Full EVM. Pure Innovation. 🚀

Built for the PureChain ecosystem - where blockchain development costs nothing!

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

purechainlib-2.0.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

purechainlib-2.0.0-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file purechainlib-2.0.0.tar.gz.

File metadata

  • Download URL: purechainlib-2.0.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.12

File hashes

Hashes for purechainlib-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1d8785fc2a365ee2d431f1d708710ce8cf2a3eac0c5e49ea3ff9d230a8383c74
MD5 37e62185498f1fe18673eee205463cf1
BLAKE2b-256 b341511bacbe7d775f552645d83fc022bd3d9de371a3206aaab5a9453e6e57e3

See more details on using hashes here.

File details

Details for the file purechainlib-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: purechainlib-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.12

File hashes

Hashes for purechainlib-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c91b017c62db0d178f92bf6b74e9c6f44c7111f6e3f10a5898063ddeca62c97
MD5 c3f2516148a4976e9754f2e78751437b
BLAKE2b-256 ccde1621a9f72e6e831a40b5a5f803075678c6145546f5beaf02b53018d46aab

See more details on using hashes here.

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