Overview
Transaction execution is the process of sending operations to the Starknet blockchain. Starkzap provides multiple ways to execute transactions, from simple contract calls to complex batched operations. What is a transaction? A transaction is a request to execute a function on a smart contract deployed on Starknet. Think of it like calling an API endpoint—you’re invoking a function on a deployed contract that performs some action (like transferring tokens, updating state, or executing business logic). Requirements:- A smart contract must be deployed on Starknet before you can execute transactions against it
- Your wallet account must be deployed (the SDK handles this automatically with
deploy: "if_needed") - Sufficient balance to pay for gas fees (unless using a paymaster for sponsored transactions)
Want to deploy your own smart contracts? This guide focuses on executing transactions against existing contracts. If you need to create and deploy your own smart contracts, check out the Starknet Quickstart Guide for comprehensive tutorials on smart contract development with Cairo.
Direct Execution
Usewallet.execute() for arbitrary contract calls:
Multiple Calls (Atomic Batching)
Multiple calls execute atomically in a single transaction:Transaction Tracking
Everyexecute(), deploy(), or transfer() call returns a Tx object:
Sponsored (Gasless) Transactions
If the SDK is configured with a paymaster, passfeeMode: "sponsored":
The SDK works seamlessly with AVNU Paymaster for sponsored transactions. See the AVNU Paymaster Integration guide for setup instructions.
Cartridge Controller: If you’re using Cartridge Controller as your wallet strategy, transactions are automatically sponsored by Cartridge’s built-in paymaster. You don’t need to configure AVNU Paymaster separately or set
feeMode: "sponsored"—Cartridge handles all gas fees automatically when users approve policies. See the Cartridge Controller Integration guide for more details.Preflight Simulation
Simulate transactions before sending to check for errors:Always preflight non-trivial batches before submitting to catch errors early.
Transaction Builder
For batching multiple operations into a single atomic transaction, use theTxBuilder. This is especially useful for complex operations that need to execute together.
For detailed TxBuilder documentation, see the Tx Builder guide which covers all builder methods, preflight simulation, fee estimation, and best practices.
Fee Modes
User Pays (Default)
Sponsored
Cartridge Controller users: If you’re using Cartridge Controller as your wallet strategy, transactions are automatically sponsored by Cartridge’s built-in paymaster. You don’t need to configure AVNU Paymaster separately—Cartridge handles all gas fees automatically when users approve policies. See the Cartridge Controller Integration guide for more details.
Transaction Status
Transactions go through several states:- RECEIVED - Transaction received by the sequencer
- ACCEPTED_ON_L2 - Transaction accepted on L2 (most common success state)
- ACCEPTED_ON_L1 - Transaction finalized on L1
Error Handling
Always handle transaction errors:Best Practices
- Always preflight non-trivial batches before submitting
- Use the transaction builder for complex operations to save gas
- Handle errors gracefully and provide user feedback
- Standardize fee behavior (
user_paysvssponsored) per flow - Wait for appropriate confirmation based on your use case
Next Steps
- Learn about ERC20 Token Operations
- Explore Staking & Delegation
- Check the API Reference for detailed method signatures