Skip to content

fix!: use deposit-bearing certificates (7/8) for stake (de)registration - #871

Merged
twwu123 merged 4 commits into
mainfrom
fix/update-stake-registration-api
Nov 13, 2026
Merged

twwu123 merged 4 commits into
mainfrom
fix/update-stake-registration-api

Conversation

@lisicky

@lisicky lisicky commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

registerStakeCertificate / deregisterStakeCertificate (and the deprecated Transaction.registerStake / deregisterStake) now build the Conway certificates 7 (reg_cert) and 8 (unreg_cert), which state their deposit, instead of the legacy certificates 0 and 1. The legacy certificates are gone from the CDDL of the next era (Dijkstra), so Mesh stops producing them.

  • Both methods take an optional amount in lovelace. When it is omitted, the keyDeposit protocol parameter is used at serialization, and the builder balances with the same value. A deregistration refund must equal the deposit originally paid, so it can now be stated when keyDeposit has changed since the registration.
  • The CST serializer emits certificates 7/8. The tx-prototype encoder still produces 0/1 for a prototype without coin, so historical transactions round-trip.
  • CSLSerializer rejects stake (de)registration: whisky ignores the deposit and emits the legacy certificates.
  • The CSL parser no longer takes the deposit whisky reports for a stake registration (coin: 0 for every one), so a parsed registration is rebuilt with the keyDeposit deposit rather than 0.

Breaking changes

Unlike certificate 0, certificate 7 must be witnessed by the stake credential:

  • key credential: the stake key must sign. MeshWallet signs with one key, so the stake key needs a second instance with accountType: "stake" and signTx(tx, true);
  • script credential: attach the script with certificateScript(...) (plus a redeemer and collateral for Plutus), and the validator must accept the publish purpose.

CSLSerializer now throws on stake (de)registration; use the CST serializer, the MeshTxBuilder default.

Affect components

  • @meshsdk/common
  • @meshsdk/contract
  • @meshsdk/core
  • @meshsdk/core-csl
  • @meshsdk/core-cst
  • @meshsdk/hydra
  • @meshsdk/provider
  • @meshsdk/react
  • @meshsdk/svelte
  • @meshsdk/transaction
  • @meshsdk/wallet
  • Mesh playground (i.e. https://meshjs.dev/)
  • Mesh CLI

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Code refactoring (improving code quality without changing its behavior)
  • Documentation update (adding or updating documentation related to the project)

Related Issues

None.

Checklist

  • My code is appropriately commented and includes relevant documentation, if necessary
  • I have added tests to cover my changes, if necessary
  • I have updated the documentation, if necessary
  • All new and existing tests pass (i.e. npm run test)
  • The build is pass (i.e. npm run build)

Additional Information

The emulator tests in tx.test.ts check that certificate 7 is rejected without the script witness (MissingOrExtraScriptHashes) and without the stake key signature (MissingKeyHashes), and stake-certificates.test.ts checks that a registration parsed by the CSL parser is rebuilt with the keyDeposit deposit. CI runs only the core-cst and scalus-emulator tests, so the transaction and core-csl tests were run locally with npm run test (all 9 packages pass).

Follow-ups, not in this PR:

  • whisky: emit certificates 7/8 with the deposit (StakeRegistration::new_with_explicit_deposit, StakeDeregistration::new_with_explicit_refund, a coin on DeregisterStake) and report coin() from its parser. Then the CSL guard can go and fromObj can read the deposit again.
  • An early builder error for a script stake registration without its script, instead of the ledger rejection at submit.
  • meshjs.dev docs for stake registration: the stake key signature and the script witness.

twwu123 and others added 4 commits November 12, 2026 16:06
whisky's parser reports `coin: 0` for every stake registration, so
reading it in `baseCertFromObj` turned a CSL-parsed registration into a
certificate 7 with a 0 deposit when the body was rebuilt. The deposit is
left to the keyDeposit protocol parameter again.

Certificate 7 needs the stake credential's witness, so the emulator
tests registering a script stake credential now provide the script and
collateral. New tests pin that a missing script witness and a missing
stake key signature are rejected, and that a CSL-parsed registration is
rebuilt with the keyDeposit deposit.
@twwu123
twwu123 merged commit 482d96c into main Nov 13, 2026
1 check passed
@twwu123
twwu123 deleted the fix/update-stake-registration-api branch November 13, 2026 07:41
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