I want to know the average occupied bytes per live cell, is there a quick method?
CKB saves the total occupied bytes by all live cells in the DAO field of the block header.
As the chapter Calculation in the RFC23 says, the DAO field packs 4 integers. The forth,
U_i, represents the total
occupied capacities currently in the blockchain up to and including block
The total number of live cells is available in the CKB Explorer Cell Count Chart. We can get the total occupied bytes by obtaining the DAO field of the latest block header via RPC
get_tip_header and decode
U_i from the field. See also How to parse the DAO field in the block header? - #2 by doitian. Dividing total occupied bytes by the number of live cells gives us the average occupied bytes.
For example, as the time of writing, the latest block number is 9,579,785 in the mainnet, and its DAO field is
0x261f44ef8e3b93488ab679bc928c2700572cbef62445ee040050fe9445583107. The decoded
5,182,924,880.00000000 CKBytes. The explorer chart tells us that the total number of live cells is 1.3 million, so the average occupied bytes per live cell is 5 billion / 1.3 million ≈ 3.8 MB.
However, the result 3.8 MB seems unreasonable, since most cells do not store any data, and each takes about 61 bytes. The cause is in the genesis block. In which the transaction
0xe2fb199810d49a4d8beec56718ba2593b665db9d52299a0f9e6e75416d73ff5c creates the live cell as output
#6. This cell has 8.4 billion CKB and 6/10 are counted as occupied. If we exclude this cell, the total occupied bytes is about
5,182,924,880 - 8,400,000,000 * 6 / 10 = 142,924,800, and the average is
142,924,800 / 1.3 million ≈ 110 bytes, which is a reasonable number based on the estimation above.