Upgrading a chaincode definition on a Hyperledger Fabric channel

Upgrading a chaincode definition means incrementing the sequence, re-approving by each organization and committing at a planned moment. This page covers the steps, the decisions behind them and what to confirm before you start.

On this page

Upgrading a chaincode definition on a Hyperledger Fabric channel: what it changes and when you need it

A consortium that wants a new chaincode version or a different endorsement policy on a live channel is not making a local change. The chaincode definition is the channel-level agreement that fixes the chaincode name, version, sequence, endorsement policy, init requirement and private data collections, and every member organization must approve the same definition before it takes effect. Until the channel commits a new definition, endorsing peers keep running the old one. Planning starts with that fact: the upgrade is a governance event across organizations as much as a software deployment, and each organization needs time to install, review and approve before anyone commits.

The sequence field is the mechanism that keeps the channel consistent. It starts at 1 and is incremented each time the chaincode is upgraded or its definition is updated, according to the Fabric chaincode lifecycle documentation. A commit must carry the next sequence number, so an organization that approves an out-of-date proposal cannot silently roll the channel back. Teams should check the current sequence on the channel before drafting anything, because a mismatch between approvals and the committed sequence is one of the most common reasons an upgrade stalls. Confirm the current value with peer lifecycle chaincode querycommitted on a peer of each organization, not only from the team that prepared the proposal.

Decide first whether the change needs a new definition or only a new package. Changing an endorsement policy, the collection configuration or the version label requires a new definition and a new sequence. Changing chaincode logic is different: if the chaincode binaries change, the chaincode package must change and be reinstalled on every endorsing peer, and the new package identifier must then be approved in the definition. A package that is rebuilt without a version change, or a definition that changes without a new package, leaves peers running code that does not match what the channel agreed to. Confirm with your chaincode team which of these changes are in the release, and treat a combined change as one coordinated approval round.

Which kind of change you are rolling out and what it requires

A new version of the chaincode code is the heaviest change. The chaincode binaries are packaged into a new chaincode package, and that package must change because the code it runs has changed. Each organization installs the new package on its peers, then approves a definition that references the new package identifier. The definition's version and sequence both move forward, so the change is visible to every channel member.

  • Package: A new package is built and installed on every endorsing peer of each approving organization. The package identifier changes with the content.
  • Sequence: The definition sequence increments by one from the currently committed value. It starts at 1 for a new definition and never goes backward.
  • Version label: Update the version string so operators can tell the releases apart when they query installed packages.
  • Approvals: Each organization that must approve the definition approves it again, with the new package identifier and sequence.
  • Unchanged: Endorsement policy, collection configuration and channel membership can stay the same if you do not change them in the same commit.

Confirm before you start that every organization can build or receive the new package on time, because a partially installed package blocks the approval round for the organizations that are waiting.

How to roll out a chaincode upgrade step by step

This sequence takes a live channel from its current chaincode definition to a new committed version, with every organization's approval recorded before the definition changes on the channel. Each stage ends with a check, so a stalled approval is found before anyone commits.

  1. Confirm the current committed definition

    Start by querying the channel for the chaincode definition it has committed today, including the name, version, sequence, endorsement policy and collection configuration. Record the sequence number, because the new definition must use the next value. Ask each organization's operator to confirm which package they have installed and which definition they last approved, so no one is working from memory. This step is done when the team has a written baseline that every organization has reviewed.

  2. Build and package the new chaincode version

    The chaincode developers build the new version and package it with the Fabric peer CLI. If the chaincode binaries changed, the package must change as well, so a rebuild that produces identical code will not give you a new package. Record the package identifier that the install step will return, and store the package in your artifact repository with its checksum. This step is done when the new package exists, has a known package ID, and the team has confirmed the code change is the one that was tested.

  3. Install the package on every endorsing peer

    Each organization installs the new package on every peer that will endorse transactions for the chaincode. Installation is per peer, so an organization with several endorsing peers must complete it on all of them, not only on the anchor peer. Operators confirm the package ID with the install query on each peer. This step is done when every endorsing peer in every organization reports the new package ID, and any peer that is missing it is listed as an open item.

  4. Increment the sequence and set the new definition

    Set the new version string and increment the sequence by one from the baseline recorded in the first step. The sequence starts at 1 and rises each time the definition is upgraded or updated, so the new value must be exactly one higher than the committed sequence. Add the endorsement policy and any private data collection changes to the same proposal, because they are part of the definition being approved. This step is done when the proposed definition is written down and reviewed by the channel administrators before any organization approves it.

  5. Collect approvals from each organization

    Each organization approves the new definition from its own administrative identity using the same parameters. The approval rules come from the channel's LifecycleEndorsement policy, which by default requires a majority of organizations, so check that policy before the round starts to know how many approvals are needed. Compare the parameters in each approval against the agreed proposal, since a single mismatched field will block the commit. This step is done when each approving organization has returned its approval and the team has a list of who signed.

  6. Check approval status across the channel

    Before committing, query the approval status for the new sequence and definition from each organization's peer. The query shows which organizations have approved identical parameters and whether the set satisfies the LifecycleEndorsement policy. If an organization is missing or shows different parameters, resolve it with that organization before continuing, since a commit with insufficient approvals will fail. This step is done when the status check shows the policy is satisfied and every approving organization matches the agreed definition.

  7. Commit the definition and verify the result

    Submit the commit transaction to the channel with the required organizations endorsing it, following the endorsement requirements in your lifecycle policy. After the commit is accepted, query the channel again to confirm the new sequence and version are the committed definition. Then invoke a read-only test function on an endorsing peer from each organization to confirm the new code responds as expected. This step is done when the committed definition matches the approved one, each organization sees the new version, and the test results are recorded in your change log.

Upgrade options and when each fits

This table compares the common ways to change a chaincode definition on a live channel, from a version bump with new packages to a policy-only change. Read each row against your change, then check which approvals and rollout timing it needs before you schedule the commit.

OptionWhat changesApprovals neededMain risk
Version bump with new chaincode binariesNew package with a changed label and code, new package ID, incremented sequenceEvery org that must endorse installs the package, then each org approves the new definitionSome peers still run old code, so endorsements and commits can diverge until all approvals land
Endorsement policy change without new codeSame package and version, updated endorsement policy, sequence still incrementedApprovals from the orgs that the lifecycle rules require, typically a majority of the channel's lifecycle endorsement policyA stricter policy can block transactions if an org is offline or its peers are not yet updated
Definition update only (collections or init settings)Collection configuration or init-required flag changes, sequence incremented, package unchangedRe-approval by each org against the new definition, as with any sequence changeMismatched collection settings across orgs can stall private data writes after commit
Immediate commit once approvals are inCommit runs as soon as enough orgs have approved the same definitionCommit needs approvals from the required orgs at the same sequencePeers that have not installed the package or approved may fail to endorse right after the commit
Staged rollout in a maintenance windowPackages installed and approvals gathered before a planned commit time, with a freeze on other channel changesSame approvals as the immediate path, plus change sign-off for the windowWindow slips or a late approval forces a rollback to the prior sequence
Test on a non-production channel firstSame package, version and policy applied to a staging network with matching org layoutInternal sign-off only, since no production members approveStaging differs from production in peer versions, org count or policy, so results may not carry over

Timing the commit so endorsements keep working

The commit is the moment a new chaincode definition becomes the one peers use to validate and endorse transactions, so the timing decision is really about whether every endorsing peer can run the new code before the definition goes live. Confirm that every organization has installed the new package on its endorsing peers and approved the same definition before anyone sends the commit. A commit that arrives while some peers still run the old binaries or lack the new package can leave endorsement requests failing for the organizations that fell behind. Check each organization's approval status with peer lifecycle chaincode checkcommitreadiness against the same channel, sequence, version and endorsement policy, and treat any mismatch as a reason to hold the commit.

Coordinate the commit window with the application teams that submit transactions to this chaincode. Ask them which transaction types change behavior under the new version, whether clients cache endorsement policies or chaincode names, and how they handle in-flight transactions during the switch. Transactions endorsed under the old definition that reach ordering after the commit are validated against the policy in force when they were endorsed, so a short overlap is normal, but a planned freeze on new submissions for the riskiest functions is a simple control to agree in advance. The Fabric Gateway client API is compatible with both v2.5 and v3.0, which means client applications can be updated on their own schedule, yet clients still need to be tested against the new chaincode version they will call.

Plan for rollback limits before committing. Fabric does not offer a simple way to revert a committed sequence. Once a higher sequence is committed, the earlier definition cannot be reinstated by committing the old version again, because the sequence must always move forward. Recovery therefore means shipping a further corrective upgrade with a new sequence, so the test environment, the approval round and the package reinstall need to be ready before the production commit. Ask your team to document who can approve an emergency follow-up, how long the approval round takes across your consortium, and which application functions can be paused if the corrected version is not ready.

Where chaincode upgrades go wrong on live channels

Most failed chaincode upgrades are not code failures. They come from mismatches between organizations, peers and clients that only surface at commit time or during the first transaction after it. Each card below names one failure, the symptom it produces and the check that catches it before endorsements break.

Mismatched package IDs across peers

Each peer computes a package ID from the installed package, and the approval must reference the same ID on every organization. If one organization built its package from a different source tree or with different build flags, its approval points at a package its peers do not hold. To detect this, run peer lifecycle chaincode queryinstalled on every endorsing peer and compare the package IDs against the ones named in the approvals before anyone signs the commit.

Approvals from the wrong organizations

A definition commits only when the approvals meet the channel's LifecycleEndorsement policy, which is often a majority of organizations. Approvals can be sent for an outdated sequence, or by an organization that has since left the channel, so the commit looks ready but fails. Check the readiness output with peer lifecycle chaincode checkcommitreadiness for the exact sequence, version and collection config, and confirm each named organization is still a current member of the channel.

Sequence reused or skipped

The sequence starts at 1 and must increase by one each time the definition changes. Reusing a sequence number with a new version or policy causes the approvals to conflict with the committed definition, and organizations that approved the wrong sequence must start again. Before proposing an upgrade, query the committed definition on the channel and set the next sequence from that value, not from memory or a previous runbook.

Endorsement policy that cannot be satisfied

A new endorsement policy can name organizations or roles that have no peer running the chaincode, or require more signatures than the online peers can provide. Once committed, transactions that fail the policy are rejected, and the damage is visible only when business traffic starts failing. Test the new policy against the peers that will endorse in production, and confirm that enough peers from the required organizations are online and have the new package installed.

Missed peer installs

Organizations approve a definition, but individual peers that were offline or skipped the install step cannot execute the new chaincode. Those peers return errors for endorsement requests while the rest of the network appears healthy, which makes the fault easy to miss. After the commit, query installed packages and the committed definition on each endorsing peer, and check the chaincode container logs for the new package ID on every peer that serves endorsements.

Client applications not updated

Client applications that hard-code the old chaincode name, version or endorsement expectations keep submitting transactions the upgraded network handles differently. Gateway clients built against the Fabric Gateway client API can be released separately from the network, but the application configuration still has to match the committed definition. Before the commit window, confirm which applications call the chaincode, update their configuration and run a test transaction against the upgraded definition in a staging channel.

Questions teams ask before upgrading chaincode on a live channel

What drives the cost and effort of a chaincode upgrade?

Cost follows the number of organizations, the number of channels and peers, and how much the chaincode itself changes. A version bump that only fixes logic is far cheaper than a change that also alters the endorsement policy, the private data collections or the chaincode's external dependencies. Each approving organization spends internal time reviewing the new package and approving the definition, so a consortium with many members has more coordination effort even when the code change is small. Ask any partner for a quote built from a written scope that lists the channels, the organizations, the peers per organization, the chaincode languages and whether a test network is included. One-time work covers the first upgrade pipeline and test runs. Recurring work covers each later upgrade cycle and any patch releases.

How long does a chaincode upgrade take on a live channel?

The duration depends on how many approval rounds the consortium needs, how quickly each organization can build and install its package, and how much testing happens before the commit. The technical steps are short, but organizations often need internal change approvals, security review of the new code and a agreed window for the commit. Each organization must install the new package on its peers and approve the new sequence before the commit can happen, so the slowest member sets the pace. Confirm the schedule with your change board and with each consortium member before work starts, since no fixed duration applies to every network.

What does the consortium need to provide for an upgrade?

The consortium needs a named contact and a decision maker in each organization, along with time for review and approval. Each member must be able to package or receive the new chaincode, install it on its own peers, and approve the new definition with the correct sequence number. The sequence starts at 1 and increments with each upgrade or definition update, so every organization must agree on the same number and parameters before the commit. If chaincode binaries change, the package itself must change and be reinstalled, so the team building the package needs the source and build pipeline agreed in advance. Members should also agree on the endorsement policy, any private data collection changes and the commit timing.

Can an internal team upgrade chaincode without a partner?

Yes, an internal team with Fabric operations skills can run the upgrade if it has the package build process, peer access and the approval workflow in place. The lifecycle steps are documented in the Fabric chaincode lifecycle docs, so the work is mostly coordination and verification rather than new engineering. The risk is in the details: mismatched sequence numbers, a package that differs from the one tested, or an endorsement policy that the available organizations cannot satisfy. Teams new to the lifecycle often benefit from a rehearsal on a test network first. A partner can take on the package pipeline, the rehearsal or the change runbook, which is priced from the written scope.

How is a failed approval round handled during an upgrade?

A failed approval round means one or more organizations did not approve the same definition before the commit, so the commit does not proceed. The fix is to find the mismatch, which is usually a different package identifier, sequence number, endorsement policy or collection configuration, then have every organization approve the corrected definition. Because the sequence number only moves forward with a new definition, teams should record which parameters each organization approved and agree the final values in writing. Keep the existing definition running during the retry so endorsements continue to work. Build a rollback plan that names the previous package and sequence before the round starts.

Should the chaincode upgrade happen with a Fabric version upgrade?

Keep the two changes separate where possible, so that a problem can be traced to one cause. Fabric's upgrade guide describes a sequence of backing up, upgrading orderer and peer binaries in a rolling fashion, then updating channel capability levels. The chaincode definition is a separate channel operation with its own approvals. Combining them increases the number of approval rounds and the risk window. The Fabric Gateway client API is compatible with both v2.5 and v3.0, so client applications can move on their own schedule. Confirm the target Fabric line and the migration prerequisites with your partner or against the Fabric upgrade docs before you schedule either change.

What should be tested before committing a new chaincode definition?

Test the exact package that will be installed, the exact sequence and endorsement policy, and the client calls that depend on the new version. Run the upgrade on a non-production network with the same channel layout and organizations where possible. Confirm that endorsements succeed under the new policy with the peers you expect to be online, and that the old definition can still serve requests until the commit. Record the package identifier and sequence used in the test so production matches it exactly. Ask your team or partner to show these checks in the written scope and in the change record.

How the upgrade moves from package to committed definition

The upgrade starts with a new chaincode package, which each organization installs on its own peers. The sequence number is then incremented and every organization approves the same definition. Before commit, check whether enough approvals exist: if they are incomplete, the flow returns to approval rather than committing, because a commit that fails the lifecycle endorsement policy will be rejected. Client rollout comes only after the commit succeeds.

Phases from new package to committed chaincode definition, with the approval gate.

How DeployOpen scopes and delivers a chaincode upgrade

DeployOpen treats a chaincode upgrade as a governed change to a live network, not only a code release. We agree the scope in writing, prepare the new package and definition, coordinate approvals across member organizations, and hand over a runbook your operators can repeat.

How we scope

  • Inventory each channel, the current chaincode definition sequence, and which organizations must approve the change.
  • Record whether the upgrade changes chaincode binaries, the endorsement policy, the collection configuration, or all three.
  • Agree in writing the channels, organizations, peers and approval rounds covered, before any work starts.

How we build

  • Prepare the new chaincode package with a changed package identifier, so each peer installs it separately from the prior version.
  • Draft the next sequence number and the new definition, then check the endorsement policy against the organizations that will sign.
  • Rehearse the approval and commit sequence on a test channel that mirrors the production membership and policy.

How we hand over

  • Deliver a runbook listing each organization's install, approve and commit steps, with the exact order and the checks before each step.
  • Document the rollback position, including which definition remains committed if an organization has not yet approved the change.
  • Walk your operators through a dry run so the next upgrade follows the same procedure without DeployOpen on call.

How we support

  • Confirm after commit that every peer reports the new definition and that endorsement succeeds against the agreed policy.
  • Offer ongoing support, upgrades and continuous testing as a retainer if your release cadence needs a standing partner.
  • Ask for a quote built from the written scope, with the channel count, organization count and test effort itemized.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.