Skip to content

contracts: instrument NFT, one catalogue per publisher, sales left to marketplaces - #269

Draft
petersalomonsen wants to merge 2 commits into
masterfrom
instrument-nfts
Draft

petersalomonsen wants to merge 2 commits into
masterfrom
instrument-nfts

Conversation

@petersalomonsen

@petersalomonsen petersalomonsen commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Adds a NEAR contract that is one publisher's catalogue of Faust instruments and songs, with their source on-chain. When a song sells on a marketplace, its royalty goes to the owners of the instruments it credits.

This is a draft: the contract is tested, but it isn't on mainnet and the app doesn't use it yet.

What's here

  • contracts/instrument-nft/src/lib.rs: the contract. See the README for its calls and limits.
  • contracts/instrument-nft/e2e/contract.test.mjs: 19 tests against a real NEAR sandbox.
  • instrument-nft job in .github/workflows/main.yml: builds from scratch and runs those tests.

Design decisions to review

  • One contract per publisher. Only the owner publishes and posts JavaScript, so a bad script can only affect that publisher's own contract.
  • Sales stay outside. No buy, listings or held earnings. Marketplaces use NEP-178 approvals and NEP-199 payouts, so the contract holds no sale money.
  • JavaScript decides, Rust caps. The owner's script can divide a work's royalty among any accounts, but Rust refuses anything above the royalty the work declared. It has no call that writes state or sends money.
  • No factory yet. The same code can be deployed per publisher now. A factory can come later without changing it.
  • Separate from the album. webassemblymusic.near stays untouched, because holding any token there grants other things, including git proxy access.

Trade-offs

  • Royalties for an instrument in another contract go to a fixed payee, because a view call can't read that contract's owner. Within one contract, they follow the NFT.
  • Exact copies are refused only within one contract.
  • A credit to another contract isn't verified on-chain.

Measured

Call TGas (sandbox)
publish_instrument 7.5
nft_transfer_payout, default rule 5.2
nft_transfer_payout, JS rule 7.0

The contract is 1.15 MB, which locks 11.54 NEAR.

Testing

All 19 sandbox tests pass locally. CI is running on this commit.

Testnet rehearsal on wm-instruments-mw87md4p.testnet: a song was sold for 1 NEAR on Mintbase's testnet market (market-v2-beta.mintspace2.testnet), with a 30% royalty crediting an instrument that had been transferred to a new owner. The instrument's new owner received 0.297 NEAR and the seller 0.703, and the song moved to the buyer. Paras's testnet market refused the contract because it isn't on its approved list.

A JS rule hasn't been through a real marketplace yet, only through the sandbox tests.

Before this leaves draft

  • Testnet rehearsal
  • CI job green on this rewrite
  • App and agent: publish, browse and import instruments
  • Hackathon section in the root README
  • Key policy for instruments.webassemblymusic.near decided (a deploy needs separate approval)

🤖 Generated with Claude Code

…plits

Publishing stores the source in contract state and mints a token whose ID is
the source hash. Songs name their instruments, and a sale credits those tokens,
so earnings follow the instrument's current owner. JavaScript can customize the
split, while Rust enforces the limits and holds the money.

Tested against a NEAR sandbox, which CI runs too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Deploying webassemblymusic with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7233b3c
Status: ✅  Deploy successful!
Preview URL: https://625e971f.webassemblymusic.pages.dev
Branch Preview URL: https://instrument-nfts.webassemblymusic.pages.dev

View logs

Removes buy, listings, earnings and publishing deposits, so the contract holds
no sale money. Only the owner publishes and posts JavaScript, and Rust caps
whatever the script returns at the work's declared royalty. Songs can credit
instruments in other contracts through a fixed payee.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@petersalomonsen petersalomonsen changed the title contracts: instrument NFT, Faust and song source on-chain with sale splits contracts: instrument NFT, one catalogue per publisher, sales left to marketplaces Nov 8, 2026

This branch has not been deployed

No deployments
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.

1 participant