Write the post that proves you understand your first Anchor program
Nothing exposes fuzzy understanding faster than trying to explain your own code. Today, you publish what you built, what your tests proved, and what writing it up reveals you still need to learn.
Write the post that proves you understand your first Anchor program
The fastest way to find the holes in your understanding is to try to teach someone else. Today you publish a post about the counter program you have spent the last week building and breaking, and the gaps you discover while writing become tomorrow’s reading list.
The Scenario
You have a working Anchor program. You have an initialize handler, an increment handler, an account constraint that stops the wrong wallet from incrementing someone else’s counter, a test suite with both happy and failure paths, and a notebook full of confirmations that each assertion in that suite is load-bearing. The code lives on your machine and runs green. That is real, and it is invisible. Nobody in your network knows it happened.
The Challenge
What you’ll need
- A DEV account
- Your counter program from days 57 through 61
- Your test suite, including both the happy-path and failure-path tests
- About 30 minutes of writing time
Steps
- Pick a title that names a specific outcome, not a topic. “My first Anchor program” is a topic. “How I built a counter program in Anchor and learned to trust my tests” is an outcome. The second tells a reader what they will get if they click.
- Open the post with the smallest useful code block: the accounts struct for your
Initializeinstruction. Three or four lines. Then explain in one paragraph what each field is doing. The accounts struct is where Anchor differs most visibly from a Web2 backend, so anchor your reader there first. - Show the handler body for
initialize. Explain whatctx.accountsgives you and why the handler is so short. Then showincrementand explain what the constraint you added guarantees before your code ever runs. - Move to the tests. Paste your happy-path test for
initialize, then your failure test for the unauthorizedincrementattempt. For each one, write a single sentence that says what would have to go wrong in the program for this test to fail. That sentence is the test’s reason for existing. - Close with the experiment you ran on Day 61. Pick one of the three bugs you planted, describe the change in prose (“I changed
+= 1to+= 2”), and quote the test output that caught it. End with what you would write next if you had another week. - Add the
#100DaysOfSolanatag and any other tags that fit, such as#solana,#rust,#anchor, or#testing. Publish.
What Just Happened
You discovered something while writing that the green tests had been hiding. Maybe it was a constraint whose purpose you could not articulate cleanly until you tried to put it in a sentence. Maybe it was a line in the handler you had been pattern-matching from a tutorial without really understanding. Maybe it was the realization that you could explain the happy path fluently but the failure path took three drafts to phrase. All of these are wins. The blog post is the artifact, but the gap you found is the actual deliverable.
Resources
- DEV, where you publish your post and where the cohort gathers under #100DaysOfSolana.
- The Anchor framework site and the Anchor book, useful for double-checking the names of constraints and macros while you write.
- LiteSVM, the in-process test harness behind the suite you are about to describe.
- Solana docs, a good place to link readers who need a primer on accounts or programs before they read your post.
Submission
Publish the post on DEV with the #100DaysOfSolana hashtag, then submit the post URL below.