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.

Fun Solidity

You can chat directly with ChatGPT or use a custom GPT. I originally created Solidity Scholar for Solidity, EIPs/ERCs and OpenZeppelin Contracts.

That is the original link from this 2024 post. Give any assistant the documentation and dependency versions your project actually uses. A Solidity-shaped answer can still be wrong. The compiler gets the last word. ;)

Using the Solidity Scholar / ChatGPT

Solidity ELI5

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.

Solidity-Smart-Contract-ELI5
Solidity-Smart-Contract-Metaphors

2. Dive into Solidity Details

Once you’re familiar with the basics, dive deeper. Ask ChatGPT about a specific feature: “How does inheritance work in Solidity, and what changes when two parent contracts define the same function?” Include your compiler version and ask for a small example you can compile.

3. Explore EIPs and ERCs

Ask about a specific EIP or ERC: “What does ERC-20 require, and which parts are choices made by this implementation?” Ask for the official proposal link, its status, and a comparison with the exact library version in your project. Open the references yourself.

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

“My contract doesn’t compile” gives the assistant about as much to work with as it gives your colleague. Include the full compiler error, compiler and library versions, and the smallest example that reproduces it.

Then ask for the cause, a minimal fix, and the command or test that checks it. Keep private keys and other secrets out of the example.

6. Code Snippets / Templates

You can also use ChatGPT to save time on small functions, documentation and test cases. Be specific about the behavior you want and the versions you use.

For example: “Add tests for this ERC-20 transfer function, including zero amounts, insufficient balance and the emitted event.” Read the result and run the tests. Changing token economics, such as adding a transfer fee, needs a separate design and integration review.

7. Auditing Your Solidity Smart Contracts

Solidity Auditor ChatGPT

One special mention goes to reviewing Solidity contracts. ChatGPT can help you form questions and spot suspicious assumptions. Useful variable names, the intended behavior and the surrounding code give it something concrete to work with.

  • Which assumptions does this function make about its caller?
  • What state must stay consistent before and after an external call?
  • Which boundary cases should the tests cover?

You can also focus the review:

  • Do the access checks cover every path that changes this value?
  • Can an operation fail because an unbounded collection grows?
  • Which fee and rounding assumptions does this accounting invariant require?

Treat the answers as candidates to investigate. Ask for the relevant code path, a defensive test and a proposed fix. A convincing explanation is still something to verify; use compilation, tests and human review before accepting a security finding or a patch.