.twrite
Transparent write namespace for standard contract transactions
The .twrite namespace provides standard (non-encrypted) contract write operations using eth_sendTransaction. Use this when privacy is not required and you want to minimize gas costs.
Overview
When you call contract.twrite.functionName(...), the SDK:
Encodes your function call using the contract ABI
Constructs a standard Ethereum transaction
Sends the transaction using
eth_sendTransactionReturns the transaction hash
No encryption is applied — calldata is visible on-chain to anyone.
Usage Pattern
tx_hash = contract.twrite.functionName(arg1, arg2, ...)Sync: Returns
HexBytestransaction hash immediatelyAsync: Returns
HexBytestransaction hash (mustawait)
Parameters
Function Arguments
Pass function arguments as positional parameters:
Transaction Options (Keyword Arguments)
Transaction options are passed as keyword arguments:
value
int
0
ETH value to send (in wei)
Any eth_sendTransaction param
Any
—
Standard web3.py transaction parameters
Common additional parameters:
gas— Gas limitgasPrice— Gas price (legacy)maxFeePerGas— Max fee per gas (EIP-1559)maxPriorityFeePerGas— Max priority fee (EIP-1559)nonce— Transaction nonce (auto-generated if omitted)
Examples
Sync Usage
Async Usage
Sending ETH
Custom Gas (Legacy)
EIP-1559 Gas Parameters
Custom Nonce
Combining Parameters
Return Value
Returns HexBytes containing the transaction hash.
You can:
Convert to hex string:
tx_hash.to_0x_hex()Convert to bytes:
bytes(tx_hash)Wait for receipt:
w3.eth.wait_for_transaction_receipt(tx_hash)
Privacy Implications
What's Visible
Everything is visible on-chain:
Your address (transaction sender)
Contract address (transaction recipient)
Function selector (first 4 bytes of calldata)
All function arguments (decoded in calldata)
Value transferred
Gas parameters
Transaction result (success/revert)
Example
Anyone can:
See you called
transferSee the recipient address
See the amount transferred
Decode all parameters from calldata
When to Use .twrite
Good Use Cases
Public operations — No sensitive data in calldata
Cost optimization — Lower gas costs (no encryption overhead)
Public protocols — DEX trades, public votes, open registrations
Testing — Quick tests where privacy doesn't matter
Compatibility — Interacting with contracts that expect standard transactions
Examples
When NOT to Use .twrite
Use .write Instead When
Function arguments contain sensitive data
Privacy is required (trading, private voting, auctions)
Amounts or addresses should be hidden
Compliance requires confidentiality
Examples (Use .write for these)
Comparison with Other Namespaces
.write
Encrypted calldata
TxSeismic (0x4a)
Standard + encryption overhead
Privacy-sensitive writes
.twrite
No encryption
eth_sendTransaction
Standard
Public writes, lower cost
.dwrite
Encrypted + debug info
TxSeismic (0x4a)
Same as .write
Development/debugging
Error Handling
Standard Web3.py Behavior
The .twrite namespace uses standard eth_sendTransaction under the hood. All web3.py transaction features work:
Account Management
Transaction Middleware
Gas Estimation
Best Practices
Security Checklist
Verify calldata is not sensitive — Anyone can see it
Check if privacy is required — Use
.writeif in doubtValidate recipient addresses — Mistakes are public and permanent
Test with small amounts first — Errors are visible to everyone
Optimization Tips
Let web3.py estimate gas (don't hardcode unless necessary)
Use EIP-1559 pricing on supported networks
Batch multiple operations if possible
Consider using
.writefor high-value transactions (extra privacy worth the cost)
Common Patterns
Low-Level Alternative
Direct eth_sendTransaction call:
The .twrite namespace is more convenient as it handles ABI encoding automatically.
See Also
.write Namespace — Encrypted writes for privacy
.tread Namespace — Transparent reads
.dwrite Namespace — Debug writes
Contract Instance — Contract wrapper reference
Web3.py Documentation — Standard Ethereum transactions
Last updated

