docs/src/deploying/large_contracts.md
If your contract exceeds the size limit for a single deployment:
{{#include ../../../examples/contracts/src/lib.rs:show_contract_is_too_big}}
you can deploy it in segments using a partitioned approach:
{{#include ../../../examples/contracts/src/lib.rs:deploy_via_loader}}
When you convert a standard contract into a loader contract, the following changes occur:
After deploying the loader contract, you can interact with it just as you would with a standard contract:
{{#include ../../../examples/contracts/src/lib.rs:use_loader}}
A helper function is available to deploy your contract normally if it is within the size limit, or as a loader contract if it exceeds the limit:
{{#include ../../../examples/contracts/src/lib.rs:auto_convert_to_loader}}
You also have the option to separate the blob upload from the contract deployment for more granular control:
{{#include ../../../examples/contracts/src/lib.rs:upload_blobs_then_deploy}}
Alternatively, you can manually split your contract code into blobs and then create and deploy a loader:
{{#include ../../../examples/contracts/src/lib.rs:manual_blobs_then_deploy}}
Or you can upload the blobs yourself and proceed with just the loader deployment:
{{#include ../../../examples/contracts/src/lib.rs:manual_blob_upload_then_deploy}}
The size of a Blob transaction is constrained by three factors:
<!--Needed to disable lints because the multiline ordered list is messing with the linter. It keeps suggesting that each item is a start of a new list.--> <!-- markdownlint-disable -->{{#include ../../../examples/contracts/src/lib.rs:show_max_tx_size}}
{{#include ../../../examples/contracts/src/lib.rs:show_max_tx_gas}}
To estimate an appropriate size for your blobs, you can run:
{{#include ../../../examples/contracts/src/lib.rs:estimate_max_blob_size}}
However, keep in mind the following limitations:
Therefore, it is advisable to make your blobs a few percent smaller than the estimated maximum size.