Is there a way to check that a contract implements a certain abi in sway?

Let’s say we have a function that accepts a contract id and we need separate logic for cases when the contract deployed with this id implements the SRC20 standard or not

For this we will need to publish the ABI together with the contract, to be able to reflect the deployed contracts, etc. We don’t have that sort of publishing yet. Although, team has certain ideas to get this done quickly for now. will keep you in loop on that

1 Like

For my case anything would work. For example:

  • making let src_20 = abi(SRC20, contract_id) function return Option
  • if not, then making functions called on the src20 instance return something that might indicate that the target contract doesn’t have the specific function. Right now, I assume, in such cases the execution will just revert and there is no way to catch this in code

Just wanted to add some input :slight_smile:

There is no way right now, We’ve been looking at something similar to ERC-1820: Pseudo-introspection Registry Contract but we could probably do something better and more integrated with the rest of the ecosystem.

1 Like