Skip to content

Instantly share code, notes, and snippets.

View mverzilli's full-sized avatar

Martin Verzilli mverzilli

View GitHub Profile
@mverzilli
mverzilli / capsule_store.ts
Created April 16, 2026 08:13
getCapsule transactionAsync
import { Fr } from '@aztec/foundation/curves/bn254';
import { type Logger, createLogger } from '@aztec/foundation/log';
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
import { AztecAddress } from '@aztec/stdlib/aztec-address';
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
export class CapsuleStore implements StagedStore {
readonly storeName = 'capsule';

API Impact Report: Custom Message Handlers

Audience: dapp developers, contract developers, wallet implementors


Breaking Changes

The one behavioral change is that unknown message types now panic instead of being silently ignored. Previously, a message with an unrecognized type ID would produce a debug log and be discarded. Now:

  • An unrecognized ID in the reserved range (< 2^16) panics with a link to /errors/2
#!/usr/bin/env npx tsx
/**
* Script to analyze and compare bytecode sizes of contract functions.
*
* Usage:
* # Show bytecode sizes for current build
* npx tsx scripts/compare-bytecode-sizes.ts
*
* # Output JSON for later comparison
* npx tsx scripts/compare-bytecode-sizes.ts --json > sizes.json
@mverzilli
mverzilli / sse-example.cr
Last active July 3, 2025 10:19
Streaming server-sent events (SSE) with Crystal
### streaming-server.cr
require "http/server"
require "json"
require "uuid"
def send_sse_frame(context, &)
# SSE frame: "data: <json>\n\n"
context.response.print "data: "
yield context.response
{
"_format": "hh-sol-artifact-1",
"contractName": "WithConst",
"sourceName": "contracts/WithConst.sol",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "initialValue",
{
"_format": "hh-sol-artifact-1",
"contractName": "WithImmAddr",
"sourceName": "contracts/WithImmAddr.sol",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "initialValue",
{
"id": "691396ad53d045b6e57dad2961f33377",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.8.2",
"solcLongVersion": "0.8.2+commit.661d1103",
"input": {
"language": "Solidity",
"sources": {
"contracts/WithImmAddr.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract WithImmAddr {\n uint256 public immutable value;\n address public immutable deployer;\n\n constructor(uint256 initialValue, address initialDeployer) {\n value = initialValue;\n deployer = initialDeployer;\n }\n\n function greet() public returns(uint256) {\n return value;\n }\n}\n"
{
"id": "6e528676131d75bd50ad7a6ea7219590",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.8.2",
"solcLongVersion": "0.8.2+commit.661d1103",
"input": {
"language": "Solidity",
"sources": {
"contracts/WithLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nlibrary Greeter {\n function greet() public pure returns(string memory) {\n return \"Salutations!\";\n }\n}\n\ncontract WithLib {\n uint256 public value;\n constructor(uint256 initialValue) {\n value = initialValue;\n }\n\n function greet() public pure returns(string memory) {\n return Greeter.greet();\n }\n}\n"
{
"id": "c0a5b134cb541060e191d89568ee7726",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.8.2",
"solcLongVersion": "0.8.2+commit.661d1103",
"input": {
"language": "Solidity",
"sources": {
"contracts/WithImm.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract WithImm {\n uint256 public immutable value;\n constructor(uint256 initialValue) {\n value = initialValue;\n }\n\n function greet() public returns(uint256) {\n return value;\n }\n}\n"
{
"id": "f46b40d4bd8359107c27982f890faa9b",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.8.2",
"solcLongVersion": "0.8.2+commit.661d1103",
"input": {
"language": "Solidity",
"sources": {
"contracts/WithRevert.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract WithRevert {\n uint256 public value;\n constructor(uint256 initialValue) {\n require(initialValue > 0, \"initial value must be positive\");\n value = initialValue;\n }\n\n function greet() public returns(uint256) {\n return value;\n }\n}\n"