# Chaincode Definition Commit

Once a sufficient number of channel members have approved a chaincode definition, one organization can commit the chaincode definition to the channel. A necessary number of approvals is governed by the **Channel/Application/LifecycleEndorsement** policy, which defaults to a majority of organizations in the channel.

As the approvals are distributed to all peers by an ordering service, any organization can check whether committing the chaincode definition would be successful by issuing the **checkcommitreadiness** command. The parameters used for the **checkcommitreadiness** command are identical to the ones used to approve a chaincode for the organization. The only difference is that a package identifier is not included because it can differ across organizations.

```
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name chaincode --version 1.0 --sequence 1 --output json
```

The command will produce a JSON map that displays if a channel member has approved the parameters that were specified in the **checkcommitreadiness** command.

```
{
    "approvals": {
        "Org1MSP": true,
        "Org2MSP": true,
    }
}
```

To commit a chaincode definition, the **commit** command can be used. When committing a channel definition, the organization should target enough peers in the channel to satisfy the **LifecycleEndorsement** policy. For example, if both **Org1MSP** and **Org2MSP** are required to commit a chaincode definition, the issued **commit** command can look as follows.

```
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name chaincode --version 1.0 --sequence 1 --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:9051
```

The transaction above uses the **--peerAddresses** flag to target multiple peers from different organizations. Because the approval is distributed within each organization, any peer that belongs to a channel member can be targeted.

The **peer lifecycle chaincode querycommitted** command can be used to confirm that the chaincode definition has been committed to the channel.

```
peer lifecycle chaincode querycommitted --channelID mychannel --name chaincode
```

If the chaincode is successfully committed to the channel, the **querycommitted** command will return the sequence and version of the chaincode definition.

{% hint style="info" %}
Committed chaincode definition for chaincode 'chaincode' on channel 'mychannel':\
Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: \[Org1MSP: true, Org2MSP: true]
{% endhint %}

After the chaincode definition has been committed to the channel, the chaincode container launches on all of the peers where the chaincode has been installed, allowing channel members to start using the chaincode. It may take a few minutes for the chaincode container to start.
