Skip to content

docs(examples): add an end-to-end Canopy guestbook dApp - #14

Open
CuriQusEth wants to merge 1 commit into
canopy-network:mainfrom
CuriQusEth:claude/canopy-guestbook-dapp-avn10d
Open

docs(examples): add an end-to-end Canopy guestbook dApp#14
CuriQusEth wants to merge 1 commit into
canopy-network:mainfrom
CuriQusEth:claude/canopy-guestbook-dapp-avn10d

Conversation

@CuriQusEth

Copy link
Copy Markdown

Adds examples/guestbook, a complete runnable appchain dApp built on this SDK: a Go plugin that defines a custom post_message transaction storing an append-only on-chain guestbook, and a React + TypeScript frontend that signs and broadcasts it with no backend.

plugin/ is an overlay for canopy's plugin/go (verified against v0.1.22+beta), installed by install.sh with a backup of everything it replaces:

  • MessagePost / Post / PostCounter in proto/tx.proto, with the generated tx.pb.go shipped so protoc is not required to build
  • CheckTx validates a 20-byte author, valid UTF-8, non-empty content, and a 280 code-point limit; DeliverTx charges the fee, assigns the next id from a counter in state, and stamps the height from PluginDeliverRequest.Height
  • state prefixes 100/101, declared in CustomStatePrefixes and outside the core-reserved range; ids are big-endian in the key so a reverse range scan yields newest-first with no sorting
  • the plugin's own HTTP server exposes /v1/query/posts, /v1/query/post-counter and /v1/health, backed by the read-only QueryState path, with CORS so a browser can read the feed

frontend/ is Vite + React + Tailwind, using the SDK's subpath imports: createProtobufEncoder + registerMessageType to teach it the plugin message, WalletManager over a localStorage keystore, NodePool for RPC failover, and createAndSignTransaction for the plugin msgTypeUrl/msgBytes format. The same client powers two node scripts (npm run post / npm run feed).

Verified end to end against a local single-node chain: posts confirm on-chain with auto-incrementing ids, fees are deducted, over-long and empty content are rejected by CheckTx after mempool admission, and the browser flow was driven with Playwright at mobile, tablet and desktop widths.

Also documents the example from the root README.

Adds examples/guestbook, a complete runnable appchain dApp built on this SDK:
a Go plugin that defines a custom `post_message` transaction storing an
append-only on-chain guestbook, and a React + TypeScript frontend that signs
and broadcasts it with no backend.

plugin/ is an overlay for canopy's plugin/go (verified against v0.1.22+beta),
installed by install.sh with a backup of everything it replaces:

- MessagePost / Post / PostCounter in proto/tx.proto, with the generated
  tx.pb.go shipped so protoc is not required to build
- CheckTx validates a 20-byte author, valid UTF-8, non-empty content, and a
  280 code-point limit; DeliverTx charges the fee, assigns the next id from a
  counter in state, and stamps the height from PluginDeliverRequest.Height
- state prefixes 100/101, declared in CustomStatePrefixes and outside the
  core-reserved range; ids are big-endian in the key so a reverse range scan
  yields newest-first with no sorting
- the plugin's own HTTP server exposes /v1/query/posts, /v1/query/post-counter
  and /v1/health, backed by the read-only QueryState path, with CORS so a
  browser can read the feed

frontend/ is Vite + React + Tailwind, using the SDK's subpath imports:
createProtobufEncoder + registerMessageType to teach it the plugin message,
WalletManager over a localStorage keystore, NodePool for RPC failover, and
createAndSignTransaction for the plugin msgTypeUrl/msgBytes format. The same
client powers two node scripts (npm run post / npm run feed).

Verified end to end against a local single-node chain: posts confirm on-chain
with auto-incrementing ids, fees are deducted, over-long and empty content are
rejected by CheckTx after mempool admission, and the browser flow was driven
with Playwright at mobile, tablet and desktop widths.

Also documents the example from the root README.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants