10

I've noticed that some of the SOL required to deploy a program is refunded after the deploy. What's going on to cause this? Is it that the program is uploaded to multiple accounts and then one of them is cleared and its rent exempt balance returned to the deployer? If it is something like that, how come it's like that?

An easy way to see this is to go to https://beta.solpg.io, build and then attempt to deploy the default program, and you get a message like "Initial deployment costs 4.65 SOL but you have 2.00 SOL. 1.55 SOL will be refunded at the end."

1 Answer 1

13

Solana programs can be quite large (often > 400kB) and you cannot upload the whole program in a single transaction since the TX size limit is 1232 bytes (which also must include the pubkeys so available space for the payload is even smaller).

So in order to upload a program you need to split it up into multiple separate transactions. The way this is implemented is that you first allocate a separate buffer account and have the transactions write the pieces of the program into it. If any of the transactions fail you can retry them. After all of the pieces have been written successfully, the program is copied from the buffer account into the final program account in a single transaction.

Because you need to allocate the buffer account, the initial SOL required is higher. The buffer account remains there until either the program upload fully succeeds or you close it manually. This is to that you can retry the failed transactions if there were any. After this is done the buffer account gets closed and you get the refund.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.