DEV Community

How I Built a Counter Program in Anchor and Finally Trusted My Tests (opens in new tab)

Discussed on DEV

The first thing that surprised me about Anchor was how much work happens in the accounts struct. My Initialize struct has three fields, but the real heavy lifting sits on the counter: #[account(init, payer = authority, space = 8 + Counter::INIT_SPACE)] pub counter: Account , init tells Anchor to create a brand new account right in the transaction. payer says who pays the rent. space calculates the exact number of bytes needed. In a traditional backend I would write all that all...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help