Smart contract developers are increasingly optimistic about the role of artificial intelligence (AI) in bolstering crypto security, despite earlier reservations regarding the safety of AI-generated code. This shift in perception comes as AI tools are being strategically implemented to augment, rather than replace, human developers, providing a supplementary layer of security and efficiency.
Concerns surrounding AI-generated code are not unfounded. A November 2024 report by the Center for Security and Emerging Technology cautioned that AI-assisted programming could be detrimental to cybersecurity, citing the potential for AI to generate insecure code and the vulnerability of AI models to attacks and manipulation. The report highlighted that almost half of the code snippets produced by various AI models contained bugs, raising the specter of a negative cybersecurity feedback loop. Similarly, a July 2024 study assessing AI's secure-code pass rate across 180 tasks and 44 vulnerability types found a median rate of below 35%.
However, crypto smart contract developers and auditors are now suggesting that AI-assisted coding can lead to a safer crypto ecosystem. Developers interviewed emphasize that AI tools are primarily used to supplement their work. 0xAw, the lead developer at Base decentralized exchange, Alien Base, utilizes AI for quick reference checks and generating "cookie-cutter" code. Furthermore, 0xAw has begun to trust AI for quick sanity checks on code, acknowledging its effectiveness in identifying obvious issues. Anton Holovchenko, a senior blockchain developer at Hacken, employs Cursor, an integrated development environment with AI features, for auto-completions and templating, but still recognizes the necessity for human oversight.
AI's utility extends to various aspects of smart contract development and security. AI algorithms can analyze code structure and identify common patterns, comparing them against known vulnerabilities. This automated approach enables auditors to identify potential risks more efficiently, saving time and effort. Workik AI, for example, integrates with security tools like Slither to detect vulnerabilities such as reentrancy attacks, integer overflows, and gas inefficiencies. AI can also improve the smart contract testing process by generating and executing test cases to assess contract behavior under different conditions, identifying edge cases and potential vulnerabilities that might be missed through manual testing.
Despite the potential benefits, the integration of AI in smart contract development necessitates a cautious approach. A recent Model Evaluation & Threat Research (METR) study indicated that AI coding assistants can slow down experienced developers by 19% on familiar codebases due to the cognitive friction of tool-context shifts. The study also revealed a disconnect between perception and reality, as participants believed they worked 24% faster with AI, while objective measures showed a slowdown, highlighting the hidden review costs associated with AI-generated code.
To maximize the benefits of AI while mitigating potential risks, developers should adopt a strategic and context-aware approach. This includes reserving AI assistants for scaffold tasks, such as documentation and test scaffolding, rather than core consensus logic. Project maintainers should also implement stricter review rules for AI-assisted pull requests to safeguard protocol integrity. Furthermore, developers should remain vigilant about potential vulnerabilities in AI-generated code, including backdoors and insecure patterns learned from malicious sources.
Ultimately, the successful integration of AI in smart contract development hinges on a balanced approach that leverages AI's capabilities while maintaining human oversight and critical thinking. By using AI as a tool to augment human expertise, developers can enhance the security, efficiency, and reliability of smart contracts, fostering a safer and more robust crypto ecosystem.