The Program Registry is a server that accepts compiled Cairo programs (also known as CASM files), fetches the compiler version dynamically, computes the correct program hash, and stores the bytecode of the Cairo program along with the program hash.
The program hash is a unique calculation of the program bytecode. Based on the compiler version, the computation might vary slightly. You can also retrieve the exact hash via the cairo-run
command from cairo-lang.
Our main motivation is to have a registry of Cairo programs so that we can retrieve the compiled Cairo program using the given program hash.
Make sure to have DATABASE_URL
on .env
file.
sqlx migrate run
cargo run -r
curl --location 'http://127.0.0.1:3000/upload-program' \
--form 'program=@"./hdp.json"' \
--form 'version="0"'
response:
0x343995a543ac64616d33fa77670cfa4e498691c96c2d964a0a07181dff4ce81
curl --location --request DELETE 'http://localhost:3000/delete-program?program_hash=0x64041a339b1edd10de83cf031cfa938645450f971d2527c90d4c2ce68d7d412'
curl --location --request GET 'http://127.0.0.1:3000/get-program?program_hash=0x343995a543ac64616d33fa77670cfa4e498691c96c2d964a0a07181dff4ce81' \
--header 'Content-Type: application/json'
response will be json file of target program
request:
curl --location 'http://127.0.0.1:3000/get-metadata?program_hash=0x294cd7453d81e9633bbf295082f5a7e51e2a8714e3c59e70fc5969ea41e3da5'
response:
{
"layout": "recursive_with_poseidon",
"version": 2
}