BuidlGuidl / abi.ninja

Interact with any contract on Ethereum.
https://abi.ninja
MIT License
182 stars 69 forks source link

Fetch `@notice` comments from contract to add them as explanation of the functions #111

Open Pabl0cks opened 3 months ago

Pabl0cks commented 3 months ago

Just realized Etherscan had this feature and I think it would be nice to have it too. Maybe is only possible for verified contracts?

The only thing that scares me is it could be exploitable by bad actors, giving a secure feeling to the user, and doing different malicious stuff in the code.

Example:

etherscan-comments-1

etherscan-comments-2

lukaw3d commented 3 months ago

anyabi.xyz doesn't return enough data for this - Sourcify API would return userdoc and devdoc fields. For sourcify you might be able to use some code from @ethereum-sourcify/contract-call-decoder for it (tho it might get deprecated https://github.com/ethereum/sourcify/issues/1388#issuecomment-2107538816)

https://github.com/ethereum/sourcify/blob/d31d9f54d638785dedd708a2d1d9340fd1324c7e/packages/contract-call-decoder/src/lib/ContractCallDecoder.ts#L171

Pabl0cks commented 3 months ago

anyabi.xyz doesn't return enough data for this - Sourcify API would return userdoc and devdoc fields. For sourcify you might be able to use some code from @ethereum-sourcify/contract-call-decoder for it (tho it might get deprecated ethereum/sourcify#1388 (comment))

https://github.com/ethereum/sourcify/blob/d31d9f54d638785dedd708a2d1d9340fd1324c7e/packages/contract-call-decoder/src/lib/ContractCallDecoder.ts#L171

Thanks a lot for the deep insights! 🙌

I think we could get source code from Etherscan API changing action parameter to getsourcecode instead of getabi, but then we'd need to always do the Etherscan API call, and change the parsing logic.

I feel downsides might be greater than the UX benefits 😥