cartesi / rollups-contracts

Smart Contracts for Cartesi Rollups
https://cartesi.github.io/rollups-contracts/
Apache License 2.0
21 stars 39 forks source link

Upload signatures #122

Closed guidanoli closed 12 months ago

guidanoli commented 12 months ago

📚 Context

The best way to interact with smart contracts is through their ABI. They describe functions, events, errors, and the like. They are fundamental for calling functions, and retrieving event data. Sometimes, however, it's hard to have hold of the ABIs of all contracts your application may indirectly interact with.

But why would you need the ABIs of contracts you don't even interact with directly? Well, if you call a contract that calls another contract, and this contract, in turn, raises an error, the contract you first called may propagate the error to you, and you'll have to figure out how to decode it.

You will easily decode canonical errors, like Error(string), Panic(uint256), but custom errors can have any signatures, like NotEnoughBalance(address,uint256,uint256). We need, therefore, a way for the developer to easily recover a signature from its selector, with little to no extra burden in terms of dependencies.

✔️ Solution

One solution is to use a signature database, like OpenChain's. The database can be interacted with through this well-documented HTTP API. From the consumer's side, they can query this database in many ways.

From our side, we can upload the selectors of all of our contracts through forge.

📈 Subtasks