How to use ChatGPT with Solidity
Using the Solidity Scholar and other GPT tips
Welcome your new best friend as a Solidity developer: ChatGPT.
If you're a developer and not using ChatGPT yet, then what the hell are you doing? Let's explore some unique ways this can help you as a Solidity developer.
You can just chat directly with ChatGPT or you can use custom GPTs. I have created the Solidity Scholar which has the full Solidity documentation as database, along with all EIPs/ERCs and the Openzeppelin Contracts. If you want to use it, take a look at https://chat.openai.com/g/g-hzhknMfDH-solidity-scholar.
Using the Solidity Scholar / ChatGPT
1. ELI5 Solidity and Metaphors
A good strategy for understanding and learning new concepts is to ask the AI to explain like I'm 5 and/or ask it to explain it with some metaphors. It will help you understand more complicated concepts. And you can ask follow-up questions.
2. Dive into Solidity Details
Once you're familiar with the basics, dive deeper. Ask me about specific Solidity features or syntax, like "Can you explain how smart contract inheritance works in Solidity?"
3. Explore EIPs and ERCs
To understand the evolving standards, ask about specific EIPs or ERCs. For instance, "What is ERC-20 and how is it implemented in Solidity?"
4. Best Practices and Common Patterns
Ask about best practices in Solidity. You might ask, "What are some security best practices when writing Solidity contracts?"
5. Troubleshooting
If you're facing specific issues or need help debugging, feel free to ask. For example, "I'm getting an error when compiling my Solidity contract. What could be the reason?"
6. Code Snippets / Templates
You can also use ChatGPT simply to save time. For example provide an existing ERC20 contract and then ask it to add a 1% transfer fee to it. Or ask it to write full contracts, the more specific your instructions, the better the output will be.
7. Auditing Your Solidity Smart Contracts
One special mention is deserved for auditing Solidity contracts. ChatGPT can be immensely helpful here. In particular if you are using appropriate variable and function names in your Solidity code. You can ask general questions like:
- Do you see any security issues with this code?
- Can you think of exploits for this smart contract?
- Are there bugs in this code?
Or you can be more specific, if you have specific concerns:
- Are there reentrancy attack issues with this contract?
- Could there be a DOS attack for this contract?
- Does the invariance x * y = k always hold?
The more specific the questions, the more likely ChatGPT can find vulnerabilities. Obviously don't rely solely on ChatGPT for audits, it's merely one additional tool in your tool box as Solidity developer.
Solidity Developer