alexandria_evm 0.6.1
An implementation similar to Solidity bytes written in Cairo 1
This package provides a set of Cairo modules for interacting with Ethereum-compatible calldata and cryptographic primitives. It is designed to ease interoperability between Starknet and Ethereum by providing utilities for:
secp256k1 signaturespackages/evm/
├── decoder.cairo # EVM calldata decoding logic
├── selector.cairo # Function selector (keccak-based) computation
├── signature.cairo # Ethereum signature verification & address recovery
decoder.cairo — EVM Calldata DecoderThis module provides type-aware decoding of Ethereum-style calldata into felt252 spans.
uint, int, address, boolbytes, string, dynamic arraystuple, fixed bytes, function selectorSpan<felt252>let types = array![EVMTypes::Uint(256), EVMTypes::Array].span();
let decoded: Span<felt252> = ctx.decode(types);
selector.cairo — Keccak Function SelectorThis module computes EVM-style function selectors based on a hashed function signature.
Logicfelt252let data: ByteArray = "transfer(address,uint256)";
let selector_value = SelectorTrait::compute_selector(data);
signature.cairo — Ethereum Signature VerificationThis module enables signature validation and address recovery from Ethereum secp256k1 signatures, using Cairo's native secp256k1 implementation.
r, s, and v (y_parity) signature formatlet sig = Signature { r, s, y_parity };
verify_eth_signature(msg_hash, sig, expected_eth_address);
Make sure to import the relevant modules in your own contract/project:
use alexandria_evm::decoder;
use alexandria_evm::selector;
use alexandria_evm::signature;
Version 0.6.1
Uploaded 1 month ago
Cairo version ^2.12.1
Size 16.3 KB
Run the following command in your project dir
scarb add alexandria_evm@0.6.1
Or add the following line to your Scarb.toml
alexandria_evm = "0.6.1"