In this repository you can find the source behind the EVMcripsr API:
| URL | Description |
|---|---|
https://api.evmcrispr.com/cors-proxy/<url> |
CORS Proxy to Giveth GraphQL API |
https://api.evmcrispr.com/tokenlist/<chainId> |
Token List API mixing Coingecko and Superfluid |
https://api.evmcrispr.com/abi/<chainId>/<contractAddress> |
API to fetch ABIs from Etherscan and other sources |
https://api.evmcrispr.com/contract/<chainId>/<contractAddress> |
A verified contract's metadata: name, ABI, compiler settings, file list |
https://api.evmcrispr.com/source/<chainId>/<contractAddress> |
A verified contract's metadata and source files |
https://api.evmcrispr.com/experimental-eez-rpc/<chain> |
One JSON-RPC endpoint per EEZ devnet chain that routes cross-chain transactions to the front |
https://api.evmcrispr.com/ipfs/pin |
Pin a file or JSON to IPFS with a token kept on the server |
https://api.evmcrispr.com/etherscan |
The Etherscan lookups the terminal makes, with a key kept on the server |
curl -X POST 'http://localhost:3000/cors-proxy/https://mainnet.serve.giveth.io/graphql' \
-H 'Content-Type: application/json' \
--data '{"query":"query GetProjectAddresses($slug: String!) { projectsBySlugs(slugs: [$slug]) { projects { id addresses { address networkId } } } }","variables":{"slug":"evmcrispr-0"}}'
Pinning needs a Pinata token, and a token shipped in a web app can be read
out of it. This component holds the token (Spin variable pinata_jwt, a key
limited to pinFileToIPFS and pinJSONToIPFS) and puts the limits where a
client cannot skip them.
| Request | Behaviour |
|---|---|
POST /ipfs/pin, application/json |
the body pinJSONToIPFS takes (pinataContent, optional pinataMetadata, pinataOptions), forwarded byte for byte; answers {"cid": "..."} |
POST /ipfs/pin, multipart/form-data |
the body pinFileToIPFS takes, one file or a directory, forwarded byte for byte; answers {"cid": "..."} |
A pin is refused with 413 over 10 MB, 403 from a browser whose Origin
is not in ALLOWED_ORIGINS, and 429 (with Retry-After) once an address
has made PIN_LIMIT pins in PIN_WINDOW_SECS, or everyone together
PIN_TOTAL_LIMIT. The origin check only stops browsers: a caller without an
Origin header, like the CLI, is let through, so the endpoint is public
within those limits.
The address is read from CLIENT_ADDRESS_HEADER and from nowhere else, so
it has to be a header callers cannot write: Spin's own spin-client-addr by
default. If the deployment sits behind a proxy and every caller shows up
with the proxy's address, they all share one allowance; name the proxy's
header there instead. When the counts cannot be read or written the answer
is 503: without its limits the route pins nothing.
There is no route to fetch what was pinned. Readers get it from an IPFS gateway and check it against the CID themselves, which is also why nobody has to trust this service: the EVMcrispr client checks the CID a pin returns against the bytes it sent. Scripts and module files are kept to one IPFS block (256 KiB) by the client, so that check works on the plain file.
curl -X POST 'http://localhost:3000/ipfs/pin' \
-H 'Content-Type: application/json' \
--data '{"pinataOptions":{"cidVersion":0},"pinataContent":{"hello":"world"}}'
The terminal reads verified sources, lists an address's transactions and
verifies contracts on Etherscan. This component holds the key for it (Spin
variable etherscan_api_key, the one /abi already uses), so none ships
in the web app.
/etherscan takes the query of Etherscan's V2 endpoint without the
apikey, and answers what Etherscan answers:
| Request | module / action |
Parameters beside chainid |
|---|---|---|
GET |
contract / getsourcecode |
address |
GET |
contract / getcontractcreation |
contractaddresses (up to 5) |
GET |
contract / checkverifystatus |
guid |
POST |
contract / verifysourcecode |
Etherscan's form body, 4 MB at most |
GET |
account / txlist |
address, startblock, endblock, page, offset (100 at most), sort |
That is all of it: any other module or action is refused with 400, and
the query sent on is rebuilt from checked values, so a parameter that is
not in the table, an apikey included, never reaches Etherscan.
The same guards as /ipfs/pin apply, with their own numbers: 403 from a
browser whose Origin is not in ALLOWED_ORIGINS, 429 (with
Retry-After) once an address has made ETHERSCAN_LIMIT requests in
ETHERSCAN_WINDOW_SECS or everyone together ETHERSCAN_TOTAL_LIMIT, and
503 when the counts cannot be read or written.
curl 'http://localhost:3000/etherscan?chainid=100&module=contract&action=getsourcecode&address=0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d'
A web app without a key of its own, like the Assertions builder on
assertions.eth.limo, reads a contract's verified metadata and source
here; the EVMcrispr SDK asks here when it has neither a key nor an
Etherscan proxy. Both routes belong to the abi-fetcher component and
answer from one lookup: Etherscan's getsourcecode with the key /abi
uses, then the chain's Blockscout. An explorer that does not have the
contract verified, or cannot be reached, sends the lookup on to the next.
Sourcify is asked first only when the request says so with ?sourcify
(no value, or any value but 0, false, no or off). It needs no key
and answers browsers on any site, so a client like the EVMcrispr SDK asks
it directly, first, and comes here only for what it does not have:
asking it again here would only add a round trip. A client that does
not ask it itself can let this service do it in one request. Sourcify's
match and exact_match both count as verified, and a Sourcify that
does not have the contract, or cannot be reached, sends the lookup on to
Etherscan.
| Request | Answer |
|---|---|
GET /contract/<chainId>/<address> |
{"name", "abi": [...], "compilerVersion", "optimizationUsed", "runs", "evmVersion"?, "license"?, "isProxy", "files": ["<path>", ...]} |
GET /source/<chainId>/<address> |
the same, with "files": {"<path>": "<content>", ...} |
GET /source/<chainId>/<address>?file=<path> |
{"name", "files": {"<path>": "<content>"}}, that file only (its exact path, URL-encoded) |
any of them with &sourcify (or ?sourcify) |
the same, Sourcify asked first |
compilerVersion comes without Etherscan's v; evmVersion is left out
when it is the compiler's default, license when none was given. The
files are Etherscan's SourceCode read as the EVMcrispr SDK reads it: the sources
of a Standard JSON input, a flat multi-file dict, or one file named after
the contract. A proxy's implementation address is not in the
answer: it changes with every upgrade and the answer may be cached for
good, so clients read it on-chain (the EIP-1967 slot, or the proxy's own
getter).
| Status | When | Cache-Control |
|---|---|---|
200 |
verified (either route, ?file= included) |
public, max-age=31536000, immutable |
404 {"error": "contract not verified"} |
a source that answered said so, and none had it verified | public, max-age=3600 |
404 {"error": "no such file", "files": [...]} |
?file= names no file of the contract |
public, max-age=31536000, immutable |
404 {"error": "contract not found", "sources": [...]} |
no source had an answer (an unsupported chain, say), with what each said | no-store |
400 |
the chain id is not a number or the address not 0x and 40 hex digits |
no-store |
429 with Retry-After |
over a limit, see below | no-store |
502 |
no source could be reached or read (a rate limit upstream counts), and, with the cache on, nothing was kept | no-store |
503 |
the counts cannot be read or written | no-store |
A verified contract's source does not change, so a verified answer says
it may be kept for good, and the browser keeps it; an unverified one may
be verified any time, so that answer is kept for an hour. The browser's
cache is each user's own: a CDN in front of api.evmcrispr.com that
honours these headers would share it across users and spare most
lookups.
The server can keep them too, with CONTRACT_KV_CACHE = "on" in the
component's environment (anything else is off). It is off by default,
because the app's one key-value store is capped at 1,024 keys on Fermyon
Cloud's Starter plan, shared with /abi, the token lists and the rate
counts, and each kept contract takes about two keys (contract_<chain>_<address>
and source_<chain>_<address>) plus one per 900 kB of source. Turn it on
only on a plan with room for it. When on:
- a verified contract is kept for a year, as long as an ABI (and its ABI
is kept for
/abitoo), an unverified one for an hour; - the chain is spelled as a number and the address in lowercase in the keys, so every spelling of an address shares one entry;
- the store takes at most 1 MB in a value (on Fermyon Cloud and on Akamai
Functions alike), and a source can be several: anything larger is kept
in pieces of 900 kB under
<key>_part<i>, written before the entry that names them; - when no source can be reached, what was kept is answered, however old.
When off, these routes read and write nothing in the store but their counts.
Lookups spend the Etherscan quota, so they are counted like
/etherscan's requests: 429 once an address has made CONTRACT_LIMIT
in CONTRACT_WINDOW_SECS or everyone together CONTRACT_TOTAL_LIMIT,
503 when the counts cannot be read or written, the address read from
CLIENT_ADDRESS_HEADER. With the cache off every request is a lookup;
on, answers from the store are free. There is no origin check: browsers
on any site may read verified sources.
curl -i 'http://localhost:3000/contract/1/0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
curl 'http://localhost:3000/source/1/0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D?file=contracts%2Finterfaces%2FIWETH.sol'
The EEZ (Ethereum Economic Zone) devnet exposes, per chain, an execution RPC
that only accepts ordinary transactions and a cross-chain "front" that only
accepts transactions touching an EEZ cross-chain proxy (it holds them and
composes them into a sync block). Neither can estimate gas for a cross-chain
call. POST /experimental-eez-rpc/<chain> (eezL1, eezL2) is one normal
JSON-RPC 2.0 endpoint per chain that routes correctly:
| Request | Behaviour |
|---|---|
| any method | forwarded verbatim to the execution RPC (batches too) |
eth_estimateGas |
forwarded to the execution RPC; if it reverts with ExecutionNotFound() (0xed6bc750) the answer is 0xaae60 (700000) |
eth_fillTransaction |
always answered with -32601 Method not found: viem ≥2.4x tries this reth/geth extension first for local accounts and the execution RPC rejects cross-chain txs with ExecutionNotFound() before anything is signed; declining it makes clients fall back to eth_estimateGas + eth_getTransactionCount + fee queries, which are routed correctly |
eth_sendRawTransaction |
the signed tx is decoded (legacy/2930/1559/4844/7702) and simulated with eth_call on the execution RPC; if that reverts with ExecutionNotFound() the request is forwarded to the front once the front's eth_blockNumber has caught up with the execution RPC (polled every second, 30 s max), otherwise to the execution RPC |
Classification rule: a call is cross-chain when the execution RPC reverts it
with the EEZ registry's ExecutionNotFound() selector 0xed6bc750 (in
error.data or error.data.data), which is what a cross-chain proxy reverts
with outside a composed block. Undecodable payloads and unknown chains fall
back to the execution RPC / a 404 respectively; upstream failures come back as
JSON-RPC -32603 errors, malformed input as -32600.
Chains are configured in spin.toml through EEZ_CHAINS
(key=chainId,executionRpc,front;...); every RPC/front host must also be in
the component's allowed_outbound_hosts.
cast send --rpc-url https://api.evmcrispr.com/experimental-eez-rpc/eezL1 \
--private-key <key> --gas-limit 700000 \
0x5e8DEb196c29ca9D828A7120f527482AEA3750F3 'setValue(uint256)' 4242