Reconcile a NEAR contract’s storage growth after an upgrade
Adding a field to every stored record changes how much balance a contract must retain for storage. Estimate the additional requirement from measured bytes at the migration boundary.
Read account usage on both sides of execution
Use query with view_account for the contract at the parent of the migration block and again at the migration block. Subtract storage_usage. Other writes in the same block also contribute, so capture their effects when isolating the migration.
{
"jsonrpc": "2.0",
"id": 1,
"method": "EXPERIMENTAL_protocol_config",
"params": {
"block_id": "BLOCK_HASH"
}
}
Convert the new bytes using the active configuration
Replace BLOCK_HASH with the post-migration block and read runtime_config.storage_amount_per_byte. Multiply the byte delta and price using integers. If the delta is 800 and the reported price is 10000000000000000000 yoctoNEAR, the additional requirement is 8000000000000000000000 yoctoNEAR, or 0.008 NEAR.
This is a change in the account’s storage backing requirement. Execution gas belongs in the transaction cost record and should be measured separately.