Troubleshoot common errors when developing and deploying LayerZero contracts on Starknet including account, declare, deploy, and crosschain errors.
This guide catalogs common errors encountered when developing and deploying LayerZero contracts on Starknet, with explanations and solutions.
Account Errors
Account Not Deployed
Error:
Account contract at address 0x... is not deployed
Cause: You’re trying to use an account that hasn’t been deployed yet. On Starknet, accounts are smart contracts that must be deployed before use.Solution:
# 1. Check if account is createdsncast account list# 2. Fund the computed address with STRK/ETH# 3. Deploy the accountsncast account deploy \ --name your_account \ --url <YOUR_SEPOLIA_RPC_URL>
Insufficient Balance for Fee
Error:
Insufficient balance for fee. Required: X, Available: Y
Cause: Your account contract doesn’t have enough STRK or ETH to pay transaction fees.Solution:
Transaction reverted: Insufficient funds for transaction
Cause: Before deploying an account contract, the computed address must be funded. Starknet computes the address deterministically, so you can fund it before deployment.Solution:
# 1. Create account (doesn't deploy yet)sncast account create --name my_account --type oz# Output shows: Address: 0x123...# 2. Fund that address BEFORE deploying# 3. Then deploysncast account deploy --name my_account
Declare Errors
Class Already Declared
Error:
Class with hash 0x... is already declared
Cause: You’re trying to declare a contract class that already exists on the network.Solution:
# Use the existing class_hash insteadsncast deploy --class-hash <EXISTING_HASH> --arguments '...'# Or if you modified the contract, rebuild to get a new hashscarb clean && scarb build
Compilation Failed
Error:
error: could not compile `my_contract` due to previous errors
Cause: Cairo compilation errors in your contract.Solution:
# Check compilation errorsscarb build 2>&1 | less# Common issues:# - Missing imports# - Type mismatches# - Trait bound errors
Deploy Errors
Wrong Owner (UDC Footgun)
Error: After deployment, the owner is set to an unexpected address (the UDC address).Cause: When deploying via the Universal Deployer Contract (UDC), get_caller_address() in the constructor returns the UDC address, not your account.Wrong pattern:
#[constructor]fn constructor(ref self: ContractState, endpoint: ContractAddress) { // BUG: This sets UDC as owner! self.ownable.initializer(get_caller_address());}
Cause: No send or receive library configured for the pathway.Solution: Use default libraries or set custom ones:
// Usually defaults are sufficient// If you need custom libraries:endpoint.set_send_library(oapp, dst_eid, library_address);
Serialization Errors
Felt Overflow
Error:
Value does not fit in felt252
Cause: Attempting to store a value larger than ~2^251 in a felt252.Solution:
// Use u256 for large numberslet big_value: u256 = 1000000000000000000000000_u256;// When encoding for crosschain:// u256 is serialized as two felt252 (low, high)
ByteArray Encoding Error
Error:
Failed to deserialize ByteArray
Cause: Incorrect ByteArray encoding in calldata.ByteArray structure:
[ pending_word_len, // Number of bytes in pending_word data_len, // Number of 31-byte chunks data[0..data_len], // Full 31-byte chunks pending_word // Remaining bytes (< 31)]
Solution:
For short strings (< 31 bytes), use simplified encoding with --arguments:
# "MyToken" as a ByteArray using --argumentssncast invoke ... --arguments '"MyToken"'
When using --arguments, sncast handles ByteArray encoding automatically. You can pass strings directly in quotes.
Execution Errors
Unauthorized
Error:
Assertion failed: unauthorized
or
Caller is not the owner
Cause: Calling an owner-only function from a non-owner account.Solution:
Cause: Scarb/Cairo version doesn’t match project requirements.Solution:
# Check current versionscarb --version# Install correct version (check Scarb.toml for required version)asdf install scarb 2.14.0asdf local scarb 2.14.0