# starknet.go > Get the gopher Starkpilled - The Go SDK for Starknet ## Docs - [Utils Examples](/docs/utils/examples): This page provides comprehensive examples demonstrating common patterns and use cases for the utils package, from basic type conversions to advanced transaction building and deployment workflows. - [Utils Package](/docs/utils): The Utils package provides essential utility functions and helpers for Starknet development. This comprehensive toolkit simplifies common operations including data type conversions, transaction building, cryptographic operations, and unit conversions. - [Types](/docs/utils/types): Type definitions and structures used throughout the utils package. - [BigIntToFelt](/docs/utils/functions/big-int-to-felt): Converts a BigInt to a Felt value. - [BigToHex](/docs/utils/functions/big-to-hex): Converts a BigInt to a hexadecimal string. - [BuildDeclareTxn](/docs/utils/functions/build-declare-txn): Builds a declare transaction for deploying new contract classes to Starknet. - [BuildDeployAccountTxn](/docs/utils/functions/build-deploy-account-txn): Builds a deploy account transaction for creating new account contracts on Starknet. - [BuildInvokeTxn](/docs/utils/functions/build-invoke-txn): Builds an invoke transaction for executing contract functions. - [BytesToBig](/docs/utils/functions/bytes-to-big): Converts a byte slice to a big.Int. - [ETHToWei](/docs/utils/functions/eth-to-wei): Converts ETH amount to Wei. - [FeltArrToBigIntArr](/docs/utils/functions/felt-arr-to-big-int-arr): Converts an array of Felt objects to an array of big.Int objects. - [FeltToBigInt](/docs/utils/functions/felt-to-big-int): Converts a Felt value to a BigInt. - [FRIToSTRK](/docs/utils/functions/fri-to-strk): Converts FRI amount to STRK. - [GetSelectorFromNameFelt](/docs/utils/functions/get-selector-from-name-felt): Calculates the function selector from a function name as a Felt. - [GetSelectorFromName](/docs/utils/functions/get-selector-from-name): Generates a selector from a given function name, returned as a `*big.Int`. - [HexArrToFelt](/docs/utils/functions/hex-arr-to-felt): Converts an array of hexadecimal strings to an array of Felts. - [HexToBN](/docs/utils/functions/hex-to-bn): Converts a hexadecimal string to a BigInt. - [HexToBytes](/docs/utils/functions/hex-to-bytes): Converts a hexadecimal string to a byte slice. - [HexToFelt](/docs/utils/functions/hex-to-felt): Converts a hexadecimal string to a Felt value. - [HexToShortStr](/docs/utils/functions/hex-to-short-str): Converts a hexadecimal string to a short string (ASCII text). - [Keccak256](/docs/utils/functions/keccak256): Computes the Keccak256 hash of the input data. - [StrToBig](/docs/utils/functions/str-to-big): Converts a string representation of a number to a big.Int. - [StrToHex](/docs/utils/functions/str-to-hex): Converts a string to its hexadecimal representation. - [STRKToFRI](/docs/utils/functions/strk-to-fri): Converts STRK amount to FRI (smallest unit). - [Uint64ToFelt](/docs/utils/functions/uint64-to-felt): Converts a uint64 value to a Felt. - [WeiToETH](/docs/utils/functions/wei-to-eth): Converts Wei amount to ETH. - [TypedData Examples](/docs/typeddata/examples): This page provides comprehensive examples for working with TypedData (SNIP-12) in Starknet, covering common patterns and real-world use cases. - [TypedData Package](/docs/typeddata): The TypedData package provides functionality for working with typed structured data on Starknet, implementing the SNIP-12 standard for off-chain message signing with type safety and domain separation. - [GetMessageHash](/docs/typeddata/methods/get-message-hash): Generates the message hash for signing by a specific account address. - [GetStructHash](/docs/typeddata/methods/get-struct-hash): Calculates the hash of a struct according to SNIP-12 encoding. - [GetTypeHash](/docs/typeddata/methods/get-type-hash): Returns the hash of a type definition. - [EncodeData](/docs/typeddata/functions/encode-data): Encodes typed data into an array of felt values according to SNIP-12 encoding rules. - [GetRevision](/docs/typeddata/functions/get-revision): Returns the revision object for a given version number (0 or 1). - [NewTypedData](/docs/typeddata/functions/new-typed-data): Creates a new TypedData instance from type definitions, domain, and message data. - [RPC Examples](/docs/rpc/examples): Comprehensive examples for using Starknet RPC methods. - [RPC Package](/docs/rpc): The RPC package provides direct access to Starknet's JSON-RPC API (v0.9.0 specification). Use it to query blockchain data, submit transactions, and subscribe to real-time updates. - [RPC Methods](/docs/rpc/methods): The RPC methods submodule provides functionality for making RPC calls to Starknet nodes. - [SubscribeEvents](/docs/rpc/websocket/subscribe-events): Creates a WebSocket stream which fires events for new Starknet events with applied filters. Events are emitted for all events from the specified block\_id up to the latest block. If `PRE_CONFIRMED` finality status is provided, events might appear multiple times for each finality status update. If a single event is required, `ACCEPTED_ON_L2` must be selected (the default). - [SubscribeNewHeads](/docs/rpc/websocket/subscribe-new-heads): Creates a WebSocket stream which fires events for new block headers produced on Starknet. The stream sends headers for all blocks from the specified starting block up to the latest block, and continues to send new block headers as they are produced. - [SubscribeNewTransactionReceipts](/docs/rpc/websocket/subscribe-new-transaction-receipts): Creates a WebSocket stream which fires events when new transaction receipts are created on Starknet. The endpoint receives optional filters including finality statuses and sender addresses. An event is fired for each finality status update. It is possible for receipts for pre-confirmed transactions to be received multiple times, or not at all. - [SubscribeNewTransactions](/docs/rpc/websocket/subscribe-new-transactions): Creates a WebSocket stream which fires events when new transactions are created on Starknet. The endpoint receives optional filters including finality statuses and sender addresses. An event is fired for each finality status update. It is possible for events for pre-confirmed and candidate transactions to be received multiple times, or not at all. - [SubscribeTransactionStatus](/docs/rpc/websocket/subscribe-transaction-status): Creates a WebSocket stream which at first fires an event with the current known transaction status, followed by events for every transaction status update. The stream monitors a specific transaction as it progresses through different states until finalization. - [AddDeclareTransaction](/docs/rpc/methods/add-declare-transaction): Submits a declare transaction (V3) to the Starknet network to register a new contract class. Declare transactions make contract classes available for deployment by publishing the Sierra contract class and its compiled CASM hash. Once declared, the class can be deployed multiple times using deploy account or deploy system call transactions. - [AddDeployAccountTransaction](/docs/rpc/methods/add-deploy-account-transaction): Submits a deploy account transaction (V3) to the Starknet network to create and deploy a new account contract. Deploy account transactions use counterfactual deployment, allowing the account address to be determined before deployment. The nonce is always 0 for deploy account transactions since the account doesn't exist yet. - [AddInvokeTransaction](/docs/rpc/methods/add-invoke-transaction): Submits an invoke transaction (V3) to the Starknet network for execution. Invoke transactions are used to execute functions on deployed contracts. The transaction must include valid signatures, correct nonce, and sufficient resource bounds to cover execution costs. - [BlockHashAndNumber](/docs/rpc/methods/block-hash-and-number): Gets both the hash and number of the most recently accepted block on Starknet in a single RPC call. This method is more efficient than calling BlockNumber and BlockHash separately when you need both values. - [BlockNumber](/docs/rpc/methods/block-number): Gets the number (height) of the most recently accepted block on Starknet. The block number (also called block height) starts from 0 (genesis block) and increments with each new block. - [BlockTransactionCount](/docs/rpc/methods/block-transaction-count): Gets the number of transactions in a specific block without fetching the full transaction data. This is a lightweight method ideal for quickly checking block activity or monitoring transaction volume over time. The method returns a simple count, making it much more efficient than fetching full block data when you only need to know how many transactions are present. - [BlockWithReceipts](/docs/rpc/methods/block-with-receipts): Gets a block with both full transaction details and their corresponding receipts. This is the most comprehensive block query method, providing complete information about transactions and their execution results including gas usage, events emitted, execution status, and fees paid. Each transaction is paired with its receipt, making this ideal for analyzing transaction outcomes. - [BlockWithTxHashes](/docs/rpc/methods/block-with-tx-hashes): Gets a block with only transaction hashes instead of full transaction details. This method is more efficient than BlockWithTxs when you only need to know which transactions are in a block without their complete data. The response is significantly lighter, making it ideal for monitoring blocks or checking transaction inclusion. - [BlockWithTxs](/docs/rpc/methods/block-with-txs): Gets a block with all its transactions included as full transaction objects. Unlike BlockWithTxHashes which only returns transaction hashes, this method returns complete transaction details including calldata, signatures, resource bounds, and all transaction-specific fields. The method can return either a confirmed block (`Block`) or a pre-confirmed block (`PreConfirmedBlock`) depending on the block status. This can return `ErrBlockNotFound` if the specified block doesn't exist. - [Call](/docs/rpc/methods/call): Calls a contract function on Starknet without creating a transaction. This allows you to query contract state or execute view functions without paying gas fees or modifying the blockchain state. - [ChainID](/docs/rpc/methods/chain-ID): Returns the chain ID for transaction replay protection. The chain ID is used to ensure that transactions signed for one network cannot be replayed on another network. Common chain IDs include `SN_MAIN` for Starknet Mainnet and `SN_SEPOLIA` for Starknet Sepolia testnet. This method caches the result after the first call for improved performance. - [ClassAt](/docs/rpc/methods/class-at): Retrieves the contract class definition at a specific contract address and block. This is useful when you know the contract address but not the class hash, and you want to inspect the contract's code, ABI, and entry points. The method automatically resolves the class hash for the given address and returns the complete class definition. - [ClassHashAt](/docs/rpc/methods/class-hash-at): Retrieves the class hash associated with a specific contract address at a given block. This is a lightweight method that returns only the class hash identifier, which can then be used with the Class method to retrieve the full class definition. This is useful for verifying which implementation a contract is using or detecting contract upgrades. - [Class](/docs/rpc/methods/class): Retrieves the contract class definition associated with the given class hash at a specific block. This returns the complete class definition including the Sierra program, entry points, and ABI, which is essential for understanding contract functionality and interacting with contracts. - [CompiledCasm](/docs/rpc/methods/compiled-casm): Get the CASM (Cairo Assembly) code resulting from compiling a given declared contract class. CASM is the low-level compiled format that is executed on Starknet. Sierra classes are compiled to CASM before execution on the network. - [EstimateFee](/docs/rpc/methods/estimate-fee): Estimates the resources required by transactions when applied on a given state. This method simulates transaction execution without actually submitting transactions to the network, returning gas consumption and fee estimates for each transaction in the request. - [EstimateMessageFee](/docs/rpc/methods/estimate-message-fee): Estimates the L2 fee of a message sent from Ethereum L1 to Starknet L2. This method is specifically for cross-layer messaging where an L1 contract sends a message to an L2 contract with an `l1_handler` function. The estimation helps determine the gas costs before sending an actual L1->L2 message. - [Events](/docs/rpc/methods/events): Retrieves events from the blockchain matching specified filter criteria with pagination support. Events are emitted by smart contracts during transaction execution and can be filtered by contract address, event keys, and block range. - [MessagesStatus](/docs/rpc/methods/messages-status): Gets the status of messages sent from Ethereum (L1) to Starknet (L2) by a specific L1 transaction. Returns the associated L1\_HANDLER transaction hashes and statuses for all L1→L2 messages sent by the L1 transaction, ordered by the L1 transaction sending order. - [Nonce](/docs/rpc/methods/nonce): Retrieves the nonce (transaction count) for a contract account at a specific block state. The nonce is essential for ensuring transaction ordering and preventing replay attacks. Each transaction from an account must use the current nonce, which increments after each transaction. - [SimulateTransactions](/docs/rpc/methods/simulate-transaction): Simulates a sequence of transactions on a specified state and generates execution traces and fee estimates without submitting the transactions to the network. Each transaction is simulated on the state resulting from applying all previous transactions in the sequence. - [SpecVersion](/docs/rpc/methods/spec-version): Returns the version of the Starknet JSON-RPC specification being implemented by the node. This is useful for ensuring compatibility between your application and the RPC provider, as different specification versions may have different method signatures or behaviors. - [StateUpdate](/docs/rpc/methods/state-update): Retrieves the complete state changes that occurred in a specific block. This includes storage updates, newly declared contract classes, deployed contract instances, replaced classes, and nonce updates. StateUpdate is essential for blockchain indexing, analytics, state verification, and understanding how the blockchain state transitions from one block to the next. - [StorageAt](/docs/rpc/methods/storage-at): Retrieves the storage value of a contract at a specific key and block state. This method allows you to read the persistent state variables stored in a contract's storage. - [StorageProof](/docs/rpc/methods/storage-proof): Get merkle paths in one of the state tries: global state, classes, or individual contract storage. A single request can query for any mix of the three types of storage proofs (classes, contracts, and storage). This is useful for verifying state without trusting the RPC provider. - [Syncing](/docs/rpc/methods/syncing): Gets the synchronization status of the node. This method returns whether the node is currently syncing with the network and provides progress information including the starting block, current block, and highest block known to the node. - [TraceBlockTransactions](/docs/rpc/methods/trace-block-transactions): Retrieves execution traces for all transactions in a specific block, providing detailed call flow, events, messages, and state changes for each transaction. This method is useful for analyzing block-level activity and debugging multiple transactions at once. - [TraceTransaction](/docs/rpc/methods/trace-transaction): Retrieves the detailed execution trace of a specific transaction, showing the complete call flow, events, messages, and resource usage. This method is essential for debugging transaction execution and understanding complex contract interactions. - [TransactionByBlockIdAndIndex](/docs/rpc/methods/transaction-by-block-id-and-): Gets the details of a transaction by specifying the block and the transaction's index within that block. - [TransactionByHash](/docs/rpc/methods/transaction-by-hash): Gets the complete details of a transaction by its hash. This method returns full transaction information including type, calldata, signatures, resource bounds, and all transaction-specific fields. This is essential for transaction verification, analysis, and displaying transaction details. - [TransactionReceipt](/docs/rpc/methods/transaction-receipt): Gets the execution receipt of a transaction by its hash. The receipt contains execution results including success/failure status, actual fees paid, gas consumed, events emitted, messages sent, and detailed revert reasons if the transaction failed. This is essential for verifying transaction execution, analyzing costs, and debugging failed transactions. - [TransactionStatus](/docs/rpc/methods/transaction-status): Gets the transaction status, including finality status and execution status. This method can reflect if the transaction is still in the mempool or has been dropped from it. - [Paymaster Client Methods](/docs/paymaster/client-methods): This page documents all methods available on the Paymaster client for building, executing, and tracking transactions through a paymaster service. - [Paymaster Package](/docs/paymaster): The paymaster package provides a client for interacting with paymaster services that sponsor transaction fees on Starknet. This enables fee abstraction, allowing transactions to be paid by a third party (the paymaster) instead of the user, or using alternative tokens beyond the default gas token. - [Transaction Building Guide](/docs/paymaster/transaction-building): This guide provides comprehensive instructions on building and executing transactions through a paymaster service. The paymaster enables fee abstraction, allowing transactions to be sponsored or paid with alternative tokens. - [Paymaster Types](/docs/paymaster/types): This page documents all type definitions used in the paymaster package for building and executing transactions through a paymaster service. - [BuildTransaction](/docs/paymaster/methods/build-transaction): Prepares a transaction with paymaster sponsorship details. Takes the user's intended transaction calls and returns typed data that includes paymaster sponsorship, along with fee estimates and a tracking ID for monitoring. - [ExecuteTransaction](/docs/paymaster/methods/execute-transaction): Executes a sponsored transaction through the paymaster service. Submits the sponsored transaction to the Starknet network, with transaction fees paid by the paymaster service according to the terms established in BuildTransaction. - [GetSupportedTokens](/docs/paymaster/methods/get-supported-tokens): Retrieves the list of tokens supported by the paymaster for fee payment. Returns all tokens that can be used to pay transaction fees through this paymaster, with each token including its address, decimals, and current price in STRK. - [IsAvailable](/docs/paymaster/methods/is-available): Checks if the paymaster service is running and accepting requests. This performs a health check to determine if the service is operational and ready to process transactions. This should be called before attempting to build or execute transactions. - [New](/docs/paymaster/methods/new): Creates a new Paymaster client instance for interacting with a SNIP-29 compliant paymaster service. The paymaster service sponsors transaction fees, allowing users to pay with alternative tokens or have their fees covered entirely. The client automatically maintains cookies for session management. - [TrackingIDToLatestHash](/docs/paymaster/methods/tracking-id-to-latest-hash): Retrieves the latest transaction hash associated with a tracking ID. Maps a tracking ID (received from BuildTransaction) to the latest transaction hash, useful for monitoring transaction status and handling retries if a transaction fails. - [Merkle Examples](/docs/merkle/examples): This page provides comprehensive examples demonstrating how to use the merkle package functions for building Merkle trees, generating proofs, and verifying data integrity. - [Merkle Package](/docs/merkle): The Merkle package provides data structures and functions for creating and verifying Merkle trees in Starknet. This package is essential for state commitments, storage proofs, and efficient data integrity verification using Pedersen hash functions. - [Proof](/docs/merkle/methods/proof): Generates a Merkle proof for a given leaf in the tree. The proof consists of the sibling nodes needed to reconstruct the path from the leaf to the root, allowing efficient verification of membership. Returns an error if the leaf is not found in the tree. The proof size is logarithmic (log2(n)) where n is the number of leaves, and proof elements are ordered from leaf to root. - [MerkleHash](/docs/merkle/functions/merkle-hash): Calculates the Merkle hash of two big integers using the Pedersen hash function. This function ensures deterministic ordering by always hashing the smaller value first, which means `MerkleHash(a, b)` always equals `MerkleHash(b, a)`. - [NewFixedSizeMerkleTree](/docs/merkle/functions/new-fixed-size-merkle-tree): Creates a new fixed-size Merkle tree from the provided leaf values. The function builds the tree bottom-up by repeatedly hashing pairs of nodes using `MerkleHash`, stores all intermediate branches for efficient proof generation, and computes the root hash. - [ProofMerklePath](/docs/merkle/functions/proof-merkle-path): Verifies if a leaf node is part of a Merkle tree by checking the validity of a Merkle path. This function recursively validates the path from a leaf to the root, ensuring data integrity without requiring the entire tree. The proof verification works by hashing the leaf with sibling nodes at each level and comparing the final computed hash with the expected root. - [Contributing to Starknet.go](/docs/introduction/contributing): Starknet.go is an open-source Go library for Starknet developed by NethermindEth. We welcome all contributions to help enrich the Starknet community. - [Getting Started](/docs/introduction/getting-started): This guide walks you through creating your first Starknet.go application. You'll build a simple program that connects to Starknet and retrieves blockchain data. - [Installation](/docs/introduction/installation): This guide covers how to add Starknet.go to your Go project. - [Why Starknet.go?](/docs/introduction/why-starknet-go): Starknet.go is a Go library that provides a comprehensive and efficient interface for interacting with the Starknet blockchain. It is designed with performance, type safety, and developer productivity in mind. - [Class Hash Functions](/docs/hash/class-hash): Class hash functions calculate unique identifiers for Starknet contract classes. These hashes are essential for declaring contracts and verifying class deployments on the network. - [Hash Examples](/docs/hash/examples): This page provides essential examples demonstrating the most commonly used hash calculation functions in Starknet: computing class hashes, calculating transaction hashes for different transaction types, and understanding the transaction hashing workflow. - [Hash Package](/docs/hash): The Hash package provides functions for calculating transaction hashes and class hashes in Starknet. This package is essential for transaction verification, contract deployment, and tracking transactions throughout their lifecycle on the network. - [Transaction Hash Functions](/docs/hash/transaction-hash): Transaction hash functions calculate unique identifiers for Starknet transactions. Each transaction type and version has its own hash calculation method following the Starknet specification. - [Utility Functions](/docs/hash/utilities): Utility functions provide helper functionality for calculating transaction hash components, particularly for V3 transactions that use resource bounds and data availability modes. - [CalculateDeprecatedTransactionHashCommon](/docs/hash/functions/calculate-deprecated-transaction-hash-common): **Internal Helper Function**: This is a low-level utility used internally by other hash functions. Most developers should use the specific transaction hash functions ([TransactionHashInvokeV1](./transaction-hash-invoke-v1), [TransactionHashDeclareV2](./transaction-hash-declare-v2), etc.) instead of calling this directly. - [ClassHash](/docs/hash/functions/class-hash): Calculates the hash of a Sierra contract class by combining the contract class version, entry points, ABI, and Sierra program using the Poseidon hash function. - [CompiledClassHash](/docs/hash/functions/compiled-class-hash): Calculates the hash of a compiled class in CASM (Cairo Assembly) format by combining the contract class version, entry points, and bytecode using the Poseidon hash function. - [DataAvailabilityModeConc](/docs/hash/functions/data-availability-mode-conc): **Internal Helper Function**: This is a low-level utility used internally by V3 transaction hash functions. Most developers should use [TransactionHashInvokeV3](./transaction-hash-invoke-v3), [TransactionHashDeclareV3](./transaction-hash-declare-v3), or [TransactionHashDeployAccountV3](./transaction-hash-deploy-account-v3) instead. - [TipAndResourcesHash](/docs/hash/functions/tip-and-resources-hash): **Internal Helper Function**: This is a low-level utility used internally by V3 transaction hash functions. Most developers should use [TransactionHashInvokeV3](./transaction-hash-invoke-v3), [TransactionHashDeclareV3](./transaction-hash-declare-v3), or [TransactionHashDeployAccountV3](./transaction-hash-deploy-account-v3) instead. - [TransactionHashBroadcastDeclareV3](/docs/hash/functions/transaction-hash-broadcast-declare-v3): **Internal Helper Function**: This function is used internally by the Account package. Most developers should use account signing methods instead. - [TransactionHashDeclareV1](/docs/hash/functions/transaction-hash-declare-v1): **Note**: V1 transactions are deprecated. For new applications, use [TransactionHashDeclareV3](./transaction-hash-declare-v3) for V3 transactions. - [TransactionHashDeclareV2](/docs/hash/functions/transaction-hash-declare-v2): **Note**: V2 transactions are deprecated. For new applications, use [TransactionHashDeclareV3](./transaction-hash-declare-v3) for V3 transactions. - [TransactionHashDeclareV3](/docs/hash/functions/transaction-hash-declare-v3): Calculates the transaction hash for a Declare V3 transaction using the Poseidon hash algorithm. V3 introduces resource bounds, data availability modes, and paymaster support for more efficient fee management. - [TransactionHashDeployAccountV1](/docs/hash/functions/transaction-hash-deploy-account-v1): **Note**: V1 transactions are deprecated. For new applications, use [TransactionHashDeployAccountV3](./transaction-hash-deploy-account-v3) for V3 transactions. - [TransactionHashDeployAccountV3](/docs/hash/functions/transaction-hash-deploy-account-v3): Calculates the transaction hash for a Deploy Account V3 transaction using the Poseidon hash algorithm. V3 introduces resource bounds, data availability modes, and paymaster support for account deployments. - [TransactionHashInvokeV0](/docs/hash/functions/transaction-hash-invoke-v0): **Note**: V0 transactions are deprecated. For new applications, use [TransactionHashInvokeV3](./transaction-hash-invoke-v3) for V3 transactions. - [TransactionHashInvokeV1](/docs/hash/functions/transaction-hash-invoke-v1): **Note**: V1 transactions are deprecated. For new applications, use [TransactionHashInvokeV3](./transaction-hash-invoke-v3) for V3 transactions. - [TransactionHashInvokeV3](/docs/hash/functions/transaction-hash-invoke-v3): Calculates the transaction hash for an Invoke V3 transaction using the Poseidon hash algorithm. V3 introduces resource bounds, data availability modes, and paymaster support for more efficient and flexible fee payment. - [Transaction Hashing Concepts](/docs/hash/concepts/transaction-hashing): Transaction hashes are unique identifiers for Starknet transactions. Understanding how they're calculated is essential for transaction signing, verification, and debugging. - [Block Analysis](/docs/examples/block-analysis): Count transactions across multiple blocks. - [Declare Transaction Example](/docs/examples/declare): This example demonstrates how to declare a new contract class on StarkNet. Declaring a contract is the process of registering a contract class on the network before it can be deployed. - [Deploy Account](/docs/examples/deploy-account): This guide demonstrates how to deploy a new account on Starknet using Starknet.go. - [Deploy Contract with UDC](/docs/examples/deploy-contract-udc): This guide demonstrates how to deploy a smart contract using the Universal Deployer Contract (UDC) on Starknet. - [Deploy Contract](/docs/examples/deploy-contract): This guide shows how to deploy a smart contract to Starknet using Starknet.go. - [Examples Overview](/docs/examples): Welcome to the Starknet.go examples section. Here you'll find practical examples demonstrating how to use various features of Starknet.go. - [Internal Transactions](/docs/examples/internal-transactions): This guide demonstrates how to work with internal transactions in Starknet using Starknet.go. - [Invoke Contract](/docs/examples/invoke-contract): This guide demonstrates how to invoke a contract's functions on Starknet using Starknet.go. - [Invoke Contract](/docs/examples/invoke): This guide demonstrates how to send invoke transactions to call smart contract functions on Starknet. - [Paymaster](/docs/examples/paymaster): This guide demonstrates how to send transactions on Starknet with a paymaster using the SNIP-29 implementation, allowing you to pay fees with tokens other than STRK or have fees sponsored by an entity. - [Read Events](/docs/examples/read-events): This guide demonstrates how to read and process events emitted by Starknet contracts using Starknet.go. - [Simple Call](/docs/examples/simple-call): This guide demonstrates how to make simple read-only calls to Starknet contracts using Starknet.go. - [Declare Contract](/docs/examples/simple-declare): This guide demonstrates how to declare a contract on Starknet using Starknet.go. - [Typed Data](/docs/examples/typed-data): This guide demonstrates how to work with typed data for signing messages in Starknet using Starknet.go. - [WebSocket](/docs/examples/websocket): This guide demonstrates how to use WebSocket connections with Starknet using Starknet.go. - [DevNet Package](/docs/devnet): The DevNet package provides a client for interacting with Starknet DevNet - a local Starknet node for testing and development. This package enables developers to test smart contracts locally without deploying to testnets, with instant block times and full control over the network state. - [DevNet Types](/docs/devnet/types): Type definitions and structures used in the DevNet package. - [Devnet Usage](/docs/devnet/usage): The devnet usage submodule provides functionality for using Starknet development networks. - [Accounts](/docs/devnet/methods/accounts): Retrieves a list of pre-funded test accounts from the DevNet server. - [FeeToken](/docs/devnet/methods/fee-token): Retrieves information about the fee token used on the DevNet. - [IsAlive](/docs/devnet/methods/is-alive): Checks if the DevNet server is running and responding to requests. - [Mint](/docs/devnet/methods/mint): Mints tokens to a specified address for testing purposes. - [NewDevNet](/docs/devnet/methods/new-devnet): Creates a new DevNet instance to interact with a local Starknet development network. - [Curve Examples](/docs/curve/examples): This page provides essential examples demonstrating the most commonly used cryptographic operations in Starknet: hashing with Pedersen/Poseidon, signing transactions, verifying signatures, and managing keys. - [Curve Package](/docs/curve): The Curve package provides cryptographic primitives for Starknet applications, including hash functions, digital signatures, and elliptic curve operations. This package is fundamental for transaction signing, key management, and cryptographic hashing throughout the Starknet ecosystem. - [ComputeHashOnElements](/docs/curve/functions/compute-hash-on-elements): **Internal Helper Function**: This is a legacy utility that works with `*big.Int` types. Most developers should use [PedersenArray](./pedersen-array) which works with `*felt.Felt` types and is the modern approach for Starknet development. - [GetRandomKeys](/docs/curve/functions/get-random-keys): Generates a random private key and its corresponding public key on the Stark curve. The keys are cryptographically secure and suitable for production use, with the public key X coordinate serving as the Starknet account address. - [GetYCoordinate](/docs/curve/functions/get-y-coordinate): Returns the Y-coordinate given an X-coordinate on the Stark curve. This function solves the curve equation to derive the Y-coordinate from a known X-coordinate. - [HashPedersenElements](/docs/curve/functions/hash-pedersen-elements): **Internal Helper Function**: This is a low-level utility that works with `*big.Int` types. Most developers should use [PedersenArray](./pedersen-array) which works with `*felt.Felt` types instead. - [PedersenArray](/docs/curve/functions/pedersen-array): Computes the Pedersen hash of multiple field elements. This function extends the two-input Pedersen hash to handle arrays of any length, making it ideal for hashing transaction data, calldata arrays, and other multi-element structures in Starknet applications. - [Pedersen](/docs/curve/functions/pedersen): Computes the Pedersen hash of two field elements. This cryptographic hash function is used extensively throughout Starknet for Merkle trees, state commitments, and contract address calculations. The Pedersen hash is deterministic (same inputs always produce the same output), collision-resistant, and the output is always a valid field element in the Starknet field. - [PoseidonArray](/docs/curve/functions/poseidon-array): Computes the Poseidon hash of multiple field elements. This function extends the two-input Poseidon hash to handle arrays of any length, providing efficient hashing for variable-length data in SNARK-friendly applications. - [Poseidon](/docs/curve/functions/poseidon): Computes the Poseidon hash of two field elements. Poseidon is a cryptographic hash function optimized for SNARK-friendly operations and is more efficient than Pedersen for use in ZK-STARKs. - [PrivateKeyToPoint](/docs/curve/functions/private-key-to-point): Generates a public key point from a private key. This function performs scalar multiplication on the Stark curve's base point to derive the corresponding public key coordinates. - [SignFelts](/docs/curve/functions/sign-felts): Signs a message hash using felt.Felt parameters. This is the felt.Felt variant of [Sign](/docs/curve/functions/sign) that provides more ergonomic handling when working with Starknet native types. - [Sign](/docs/curve/functions/sign): Signs a message hash using the Stark curve ECDSA algorithm. This function produces a deterministic signature with R and S components that can be verified using the corresponding public key. - [StarknetKeccak](/docs/curve/functions/starknet-keccak): Computes the Starknet Keccak hash of a byte slice. This function is specifically used in Starknet for function selector calculation and event key generation. - [VerifyFelts](/docs/curve/functions/verify-felts): Verifies a signature using felt.Felt parameters. This is the felt.Felt variant of [Verify](/docs/curve/functions/verify) that provides more ergonomic handling when working with Starknet native types. - [Verify](/docs/curve/functions/verify): Verifies a signature for a given message hash using the Stark curve. This function validates that a signature was created by the holder of the private key corresponding to the provided public key. - [Contracts Examples](/docs/contracts/examples): This page provides comprehensive examples for working with the Contracts package, covering common patterns and use cases. - [Contracts Package](/docs/contracts): The Contracts package provides data structures and utilities for working with Starknet contract classes, ABIs, and deployment. This package is essential for loading contract files, parsing ABIs, computing contract addresses, and working with different contract class formats. - [PrecomputeAddress](/docs/contracts/functions/precompute-address): Calculates the precomputed address for a contract instance before deployment. - [UnmarshalCasmClass](/docs/contracts/functions/unmarshal-casm-class): Loads and unmarshals a CASM (Cairo Assembly) class from a JSON file. - [Client Functions](/docs/client/functions): This page documents the package-level functions available in the client package for creating clients, managing context, and working with server components. - [Client Package](/docs/client): The Client package provides low-level JSON-RPC communication infrastructure for interacting with Starknet nodes. This is the foundational layer that handles network communication, request/response management, and real-time subscriptions over HTTP and WebSocket connections. - [Client Methods](/docs/client/methods): This page documents the methods available on the Client type for making RPC calls, managing subscriptions, and handling batch operations. - [Account Functions](/docs/account/functions): Standalone utility functions for calldata formatting, address computation, and key management. - [Account Package](/docs/account): The Account package provides comprehensive functionality for managing Starknet accounts, building and signing transactions, and executing contract interactions. This package is the primary interface for performing on-chain operations in Starknet applications. - [Keystore](/docs/account/keystore): The Keystore interface and MemKeystore implementation provide flexible key management for Starknet accounts. - [Account Methods](/docs/account/methods): Methods available on the Account type for transaction handling, signing, and account management. - [BuildAndEstimateDeployAccountTxn](/docs/account/methods/build-and-estimate-deploy-account-txn): Builds and estimates a deploy account transaction without sending it to the network. This method precomputes the account address, builds the deploy transaction, signs it, estimates fees, updates the transaction with the estimated fees, and signs again. The returned transaction is ready to be sent, but you must fund the precomputed address with tokens before broadcasting the transaction. - [BuildAndSendDeclareTxn](/docs/account/methods/build-and-send-declare-txn): Builds, signs, estimates fees, and sends a declare transaction to register a new contract class on Starknet. This method handles the entire declaration process including nonce management, fee estimation, and transaction signing automatically. The returned class hash can be used to deploy contract instances. - [BuildAndSendInvokeTxn](/docs/account/methods/build-and-send-invoke-txn): Builds, signs, estimates fees, and sends an invoke transaction to execute contract functions on Starknet. This method handles the complete transaction lifecycle including nonce management, fee estimation, and transaction signing automatically. - [DeployContractWithUDC](/docs/account/methods/deploy-contract-with-udc): Deploys a contract instance using the Universal Deployer Contract (UDC). This method builds and sends an invoke transaction to the UDC, which creates a new contract instance from a previously declared class hash. The deployment address is deterministic based on the class hash, salt, and optionally the deployer's address. - [FmtCalldata](/docs/account/methods/fmt-calldata): Formats calldata based on the account's Cairo version (Cairo v0 or Cairo v2). This method automatically selects the appropriate calldata format based on the account's CairoVersion field. - [NewAccount](/docs/account/methods/new-account): Creates a new Account instance. - [Nonce](/docs/account/methods/nonce): Retrieves the current transaction nonce for the account from the `pending` block. The nonce is automatically managed by BuildAndSendInvokeTxn and BuildAndSendDeclareTxn. - [SendTransaction](/docs/account/methods/send-transaction): Sends a pre-built and signed V3 transaction to the network. This is a low-level method that provides a unified way to send Invoke, Declare, and Deploy Account transactions. Most users should use the higher-level methods like BuildAndSendInvokeTxn or BuildAndSendDeclareTxn instead. - [SignDeclareTransaction](/docs/account/methods/sign-declare-transaction): Signs a declare transaction by calculating the transaction hash and signing it with the account's private key. This method automatically sets the Signature field on the transaction with the resulting (r, s) signature components. Supports V1, V2, V3, and BroadcastDeclareTxnV3 declare transactions. - [SignDeployAccountTransaction](/docs/account/methods/sign-deploy-account-transaction): Signs a deploy account transaction using the account's private key. This method computes the transaction hash based on the deploy account version, signs it, and attaches the signature to the transaction, making it ready for broadcasting. - [SignInvokeTransaction](/docs/account/methods/sign-invoke-transaction): Signs an invoke transaction using the account's private key. This method computes the transaction hash based on the invoke version, signs it, and attaches the signature to the transaction, making it ready for broadcasting. Supports V0, V1, and V3 invoke transactions. - [Sign](/docs/account/methods/sign): Signs a felt message using the account's private key from the keystore. The signature is compatible with Starknet's signature verification scheme and returns two felt components (r, s). - [TransactionHashDeclare](/docs/account/methods/transaction-hash-declare): Calculates the transaction hash for a declare transaction. This method computes the hash based on the declare transaction version (V1, V2, or V3) using the appropriate hashing algorithm for each version. The computed hash is used for signing the transaction. - [TransactionHashDeployAccount](/docs/account/methods/transaction-hash-deploy-account): Calculates the transaction hash for a deploy account transaction. This method computes the hash based on the deploy account transaction version (V1 or V3) using the precomputed contract address. The computed hash is used for signing the transaction. - [TransactionHashInvoke](/docs/account/methods/transaction-hash-invoke): Calculates the transaction hash for an invoke transaction. This method computes the hash based on the invoke transaction version (V0, V1, or V3) using the appropriate hashing algorithm for each version. The computed hash is used for signing the transaction. - [Verify](/docs/account/methods/verify): Verifies a signature against a message hash using the account's public key. This method checks whether a signature is valid for a given message hash using Starknet's ECDSA curve (STARK curve) to verify the signature components against the message hash and public key. - [WaitForTransactionReceipt](/docs/account/methods/wait-for-transaction-receipt): Waits for a transaction to be confirmed on-chain. This method polls the network at regular intervals until the transaction is confirmed or the context is cancelled, handling the "transaction not found" case gracefully by continuing to poll. - [GetRandomKeys](/docs/account/keystore/get-random-keys): Generates a cryptographically random key pair using the Starknet curve. The private key is automatically stored in a MemKeystore indexed by the public key. This function is intended for testing, development, examples, and temporary accounts. - [Get](/docs/account/keystore/get): Retrieves a private key from the MemKeystore by its identifier (typically the public key as a hex string). The method is thread-safe and returns an error if the key doesn't exist. - [NewMemKeystore](/docs/account/keystore/new-mem-keystore): Creates a new empty in-memory keystore. MemKeystore is thread-safe (uses mutex), intended for testing and development, and not persistent (keys are lost when program exits). For production, implement a custom Keystore that securely persists keys. - [Put](/docs/account/keystore/put): Stores a private key in the MemKeystore indexed by a string identifier (typically the public key). The method is thread-safe and can be called multiple times to update or add keys. - [SetNewMemKeystore](/docs/account/keystore/set-new-mem-keystore): Creates a new in-memory keystore with a specified key pair. This is a convenience function equivalent to creating an empty keystore with NewMemKeystore() and then calling Put() to add the initial key pair. - [Sign](/docs/account/keystore/sign): Signs a message hash using a stored private key. This method retrieves the private key for the given identifier and uses it to sign the message hash using ECDSA on the Starknet curve. The method is thread-safe and respects context cancellation. - [FmtCallDataCairo0](/docs/account/functions/fmt-calldata-cairo0): Formats function calls into calldata for Cairo 0 contracts. - [FmtCallDataCairo2](/docs/account/functions/fmt-calldata-cairo2): Formats function calls into calldata for Cairo 2 contracts. - [PrecomputeAccountAddress](/docs/account/functions/precompute-account-address): Calculates the deterministic address for an account contract before deployment. - [Transaction Signing Concepts](/docs/account/concepts/transaction-signing): Understanding how transaction signing works in Starknet is essential for secure account management and transaction handling.