DocumentationBlog

StarkNet data format

Apibara provides data streams for all StarkNet networks:

StarkNet Mainnet

  • endpoint: mainnet.starknet.stream.apibara.com:443

StarkNet Görli Testnet

  • endpoint: goerli.starknet.stream.apibara.com:443

StarkNet Görli 2 Testnet

  • endpoint: goerli-2.starknet.stream.apibara.com:443

Protobuf definition#

// # Apibara StarkNet Support
syntax = "proto3";
package apibara.starknet.v1alpha1;
import "google/protobuf/timestamp.proto";
// A StarkNet block.
message Block {
BlockHash block_hash = 1;
BlockHash parent_block_hash = 2;
uint64 block_number = 3;
bytes sequencer_address = 4;
bytes state_root = 5;
bytes gas_price = 6;
google.protobuf.Timestamp timestamp = 7;
string starknet_version = 8;
repeated Transaction transactions = 9;
repeated TransactionReceipt transaction_receipts = 10;
}
// The hash of a StarkNet block.
message BlockHash { bytes hash = 1; }
// Status of a transaction.
enum TransactionStatus {
TRANSACTION_STATUS_UNSPECIFIED = 0;
TRANSACTION_STATUS_RECEIVED = 1;
TRANSACTION_STATUS_PENDING = 2;
TRANSACTION_STATUS_ACCEPTED_ON_L2 = 3;
TRANSACTION_STATUS_ACCEPTED_ON_L1 = 4;
TRANSACTION_STATUS_REJECTED = 5;
}
message Transaction {
oneof transaction {
InvokeTransaction invoke = 1;
DeployTransaction deploy = 2;
DeclareTransaction declare = 3;
L1HandlerTransaction l1_handler = 4;
DeployAccountTransaction deploy_account = 5;
}
}
message TransactionCommon {
bytes hash = 1;
bytes max_fee = 2;
repeated bytes signature = 3;
bytes nonce = 4;
bytes version = 5;
}
message InvokeTransaction {
TransactionCommon common = 1;
bytes contract_address = 2;
bytes entry_point_selector = 3;
repeated bytes calldata = 4;
}
message DeclareTransaction {
TransactionCommon common = 1;
bytes class_hash = 2;
bytes sender_address = 3;
}
message DeployTransaction {
TransactionCommon common = 1;
repeated bytes constructor_calldata = 2;
bytes contract_address = 3;
bytes contract_address_salt = 4;
bytes class_hash = 5;
}
message L1HandlerTransaction {
TransactionCommon common = 1;
bytes contract_address = 2;
bytes entry_point_selector = 3;
repeated bytes calldata = 4;
}
message DeployAccountTransaction {
TransactionCommon common = 1;
repeated bytes constructor_calldata = 2;
bytes contract_address = 3;
bytes contract_address_salt = 4;
bytes class_hash = 5;
}
message TransactionReceipt {
bytes transaction_hash = 1;
uint64 transaction_index = 2;
bytes actual_fee = 3;
ExecutionResources execution_resources = 4;
L1ToL2Message l1_to_l2_consumed_message = 5;
repeated L2ToL1Message l2_to_l1_messages = 6;
repeated Event events = 7;
}
message ExecutionResources {
uint64 n_steps = 1;
uint64 n_memory_holes = 2;
BuiltinInstanceCounter builtin_instance_counter = 3;
}
message BuiltinInstanceCounter {
optional uint64 pedersen_builtin = 1;
optional uint64 range_check_builtin = 2;
optional uint64 bitwise_builtin = 3;
optional uint64 output_builtin = 4;
optional uint64 ecdsa_builtin = 5;
optional uint64 ec_op_builtin = 6;
}
message L1ToL2Message {
bytes from_address = 1;
bytes to_address = 2;
bytes selector = 3;
repeated bytes payload = 4;
bytes nonce = 5;
}
message L2ToL1Message {
bytes from_address = 1;
bytes to_address = 2;
repeated bytes payload = 3;
}
message Event {
bytes from_address = 1;
repeated bytes keys = 2;
repeated bytes data = 3;
}