Arkade Types
Data types in the Arkade Script language
Experimental Technology
The Arkade Language is experimental technology in active development. All code and examples presented here are for exploration and proof of concept purposes only. Do not use in production environments.
Arkade Types
Arkade Script provides a rich set of data types designed specifically for Bitcoin smart contracts. These types help ensure contract correctness and provide clear semantics for working with Bitcoin’s UTXO model.
Primitive Types
Boolean
The bool
type represents a boolean value (true or false):
Boolean values are used in conditional statements and logical operations.
Integer
The int
type represents a signed integer:
Integers in Arkade Script are implemented as 64-bit signed integers, allowing for a range from -2^63 to 2^63-1.
Cryptographic Types
Public Key
The pubkey
type represents a Bitcoin public key:
Public keys are used for signature verification and address generation.
Signature
The signature
type represents a Bitcoin signature:
Signatures are typically provided as function parameters and used with checkSig
or checkMultisig
functions.
Byte Arrays
Generic Bytes
The bytes
type represents an arbitrary byte array:
Byte arrays can be used for arbitrary data storage and manipulation.
Fixed-Size Bytes
Fixed-size byte arrays specify the exact number of bytes:
Common fixed-size types include:
bytes20
: Typically used for RIPEMD-160 hashes or Hash160 resultsbytes32
: Typically used for SHA-256 hashesbytes33
: Typically used for compressed public keys
Asset Types
Asset
The asset
type represents an Asset:
Asset types are used for working with assets in contracts. They provide identifiers and the terms of the asset, such as supply.
Complex Types
Arrays
Arrays can hold multiple values of the same type:
Arrays support indexing and length properties:
Structs
Structs group related data together:
Struct fields are accessed using dot notation:
Type Conversion
Explicit Conversion
Explicit type conversion is performed using casting syntax:
Implicit Conversion
Some types can be implicitly converted:
- Integer literals to
int
- String literals to
bytes
- Hex literals to
bytes
or fixed-size byte arrays
Special Types
Transaction
The tx
object provides access to transaction data:
Input
The input
type represents a transaction input:
The current input being spent can be accessed directly:
Output
The output
type represents a transaction output:
Type Properties
Size
The size of a value in bytes can be obtained using the size
property:
Type Checking
The type of a value can be checked at runtime:
Null Values
Some types can be null, indicating the absence of a value:
Type Safety
Arkade Script is statically typed, meaning type checking is performed at compile time:
This helps catch errors before contracts are deployed.
Memory Layout
Understanding how types are represented in memory can be important for advanced contract development:
bool
: 1 byte (0 for false, 1 for true)int
: 8 bytes (little-endian)pubkey
: 33 bytes (compressed) or 65 bytes (uncompressed)signature
: 64 bytes (Schnorr) or 71-73 bytes (ECDSA)bytes
: Variable length with size prefix
Conclusion
Arkade Script’s type system is designed to provide both safety and expressiveness for Bitcoin smart contract development. By using appropriate types, you can make your contracts more readable and less prone to errors.
For more information on how to use these types with functions, see the Arkade Functions page.