What is a good way to put the equivalent of a captcha in a Solidity contract? The objective is to put in a filter to make it difficult for bots to monopolize the contract, allowing regular humans to have access. For example, I could put in a string like 'what is seven times eight' or 'what are the first 5 digits of pi'? and then a user would have to input the answer with his transaction.
I'll go a little bit out on a limb and suggest that the need for a CAPTCHA suggests an underlying design issue that needs to be discovered, defined and addressed.
Bots, other contracts and humans are (generally) indistinguishable, by design. Contracts are designed to enforce rules reliably. The rules can enforce business logic and assure incentives that make systems work economically. I would suggest decomposing the concerns that make it seem like differentiating between humans and bots (who play by the rules) is a good idea or necessary. In summary, you shouldn't want to.
Is it a spam concern, regulatory concern, something else?
I would be open-minded about fundamental requirements that are not anticipated but my instinct is that this a presumptive solution to a set of unknown concerns. It only looks like a requirement. It may be pointing the way to a critical oversight so I would work on bringing that into to the open.
Hope it helps.
Unfortunately CAPTCHA paradigm is based on the introduction, from outside, of a data to be decoded. This means that there is not some locally inspectable code to use as a guideline to answer the question. This is not the case in ethereum smart contract, which are inspectable by definition. In such a way any internal code useful to understand if the question has been properly answered is available to design the bot.
The only solution can be using oracles, i.e. systems out of the chain which interface your contract by the web or whatsoever.
Nothing strange to interface the true CAPTCHA server at that point or something similar.
Anyway, may be that it be a wrong paradigm for the blockchain and a costly implementation with minor real world results.