Experimental TechnologyThe 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 Functions
Arkade Script provides a comprehensive set of built-in functions for common operations in Bitcoin smart contracts. These functions abstract away the complexity of Bitcoin Script while providing powerful capabilities for contract development.Signature Verification
checkSig
Verifies a signature against a public key:signature
: The signature to verifypubkey
: The public key to verify against
bool
: True if the signature is valid, false otherwise
checkMultisig
Verifies multiple signatures against multiple public keys:pubkeys
: Array of public keyssignatures
: Array of signatures
bool
: True if all signatures are valid, false otherwise
checkSigFromStack
Verifies a signature against a message and public key:signature
: The signature to verifypubkey
: The public key to verify againstmessage
: The message that was signed
bool
: True if the signature is valid, false otherwise
Hash Functions
sha256
Computes the SHA-256 hash of data:data
: The data to hash
bytes32
: The SHA-256 hash
ripemd160
Computes the RIPEMD-160 hash of data:data
: The data to hash
bytes20
: The RIPEMD-160 hash
hash160
Computes the Hash160 (SHA-256 followed by RIPEMD-160) of data:data
: The data to hash
bytes20
: The Hash160 result
hash256
Computes the double SHA-256 hash of data:data
: The data to hash
bytes32
: The double SHA-256 hash
Timelock Functions
checkLockTime
Verifies that the transaction’s locktime meets a requirement:locktime
: The minimum required locktime
bool
: True if the transaction’s locktime is greater than or equal to the specified locktime
checkSequence
Verifies that the input’s sequence number meets a requirement:sequence
: The minimum required sequence
bool
: True if the input’s sequence is greater than or equal to the specified sequence
Conversion Functions
int2bytes
Converts an integer to a byte array:value
: The integer to convert
bytes
: The byte representation of the integer
bytes2int
Converts a byte array to an integer:bytes
: The byte array to convert
int
: The integer value
Script Generation
new P2PKH
Creates a Pay-to-Public-Key-Hash (P2PKH) script:pubkey
: The public key to create the script for
bytes
: The P2PKH script
new P2SH
Creates a Pay-to-Script-Hash (P2SH) script:redeemScript
: The redeem script to hash
bytes
: The P2SH script
new P2WPKH
Creates a Pay-to-Witness-Public-Key-Hash (P2WPKH) script:pubkey
: The public key to create the script for
bytes
: The P2WPKH script
new P2WSH
Creates a Pay-to-Witness-Script-Hash (P2WSH) script:witnessScript
: The witness script to hash
bytes
: The P2WSH script
new P2TR
Creates a Pay-to-Taproot (P2TR) script:internalKey
: The internal key for the Taproot outputscriptTree
(optional): The script tree for the Taproot output
bytes
: The P2TR script
Key Functions
tweakKey
Tweaks a public key with a value:pubkey
: The public key to tweaktweak
: The value to tweak with
pubkey
: The tweaked public key
aggregateKeys
Aggregates multiple public keys into a single key:pubkeys
: Array of public keys to aggregate
pubkey
: The aggregated public key
Array Functions
length
Returns the length of an array:concat
Concatenates two arrays:array1
: The first arrayarray2
: The second array
- Array containing all elements from both input arrays
Utility Functions
require
Enforces a condition, failing if it’s not met:condition
: The condition to checkmessage
(optional): Error message if the condition fails
min
Returns the minimum of two values:a
: First valueb
: Second value
- The smaller of the two values
max
Returns the maximum of two values:a
: First valueb
: Second value
- The larger of the two values
Advanced Functions
verifyTaprootSignature
Verifies a Taproot signature:signature
: The signature to verifypubkey
: The public key to verify againstmessage
: The message that was signedleafHash
: The leaf hash for the Taproot script path
bool
: True if the signature is valid, false otherwise
computeMerkleRoot
Computes a Merkle root from a list of hashes:hashes
: Array of hashes to include in the Merkle tree
bytes32
: The Merkle root