Shielded Write Complete
Full shielded write workflow from setup to confirmation
Prerequisites
# Install the SDK
pip install seismic-web3
# Set environment variables
export PRIVATE_KEY="your_64_char_hex_private_key"
export CONTRACT_ADDRESS="0x..." # Your deployed contract addressBasic Shielded Write
import os
from seismic_web3 import create_wallet_client, PrivateKey, SEISMIC_TESTNET
from hexbytes import HexBytes
# Setup
private_key = PrivateKey.from_hex_str(os.environ["PRIVATE_KEY"])
w3 = SEISMIC_TESTNET.wallet_client(private_key)
# Contract ABI (simplified example)
ABI = [
{
"name": "setNumber",
"type": "function",
"inputs": [{"name": "value", "type": "uint256"}],
"outputs": [],
},
{
"name": "getNumber",
"type": "function",
"inputs": [],
"outputs": [{"name": "", "type": "uint256"}],
},
]
# Create contract instance
contract_address = os.environ["CONTRACT_ADDRESS"]
contract = w3.seismic.contract(contract_address, ABI)
# Execute shielded write
print("Sending shielded transaction...")
tx_hash = contract.write.setNumber(42)
print(f"Transaction hash: {tx_hash.hex()}")
# Wait for confirmation
print("Waiting for confirmation...")
receipt = w3.eth.wait_for_transaction_receipt(tx_hash, timeout=60)
# Verify success
if receipt["status"] == 1:
print(f"Transaction successful!")
print(f"Block number: {receipt['blockNumber']}")
print(f"Gas used: {receipt['gasUsed']}")
print(f"Transaction type: 0x{receipt['type']:02x}")
else:
print("Transaction failed!")
raise RuntimeError(f"Transaction reverted: {tx_hash.hex()}")Complete Workflow with Verification
Custom Security Parameters
Low-Level Shielded Write
Debug Mode
Error Handling
Batch Operations
Expected Output
Common Variations
With Value Transfer
Gas Estimation
Next Steps
See Also
Last updated

