Can we configure the predicate through script?

Since we can configure the constants in predicate, is there a way to do it via scripts so that it can be indexed using the indexer, like for tracking of new orders?

A script can log an event, and it should be possible for the indexer to index all these logs. I don’t believe we have an example yet though.

The Spark team created a smart-contract only used for logging these predicate events, but that’s just a short-term solution to make it easier to index.

Furthermore, it should be possible for any Sway code (script, contract, predicate) to “calculate” a predicate address by filling in the constants, but it’s currently infeasible as the code would need to generate the entire code tree to calculate the code root. This is something we’ve discussed improving in the future.

@RahulBansal123

1 Like