solana

How can I recover the SOL used for rent after a failed Solana program deployment?


I tried to deploy a Solana program, it failed, and I lost my SOL that I used for rent. Is there any way to get it back?

Error: Deploying program failed: Error processing Instruction 1: custom program error: 0x1

Solution

  • Yes! The SOL you used for rent is still stored in the account, even if the deployment failed.

    To recover the SOL from one deployment

    After your deployment fails, you'll get an error like this:

    Recover the intermediate account's ephemeral keypair file with
    `solana-keygen recover` and the following 12-word seed phrase:
    =================================================================================
    this is a fake seed phrase really argle bargle boopity doop face
    =================================================================================
    To resume a deploy, pass the recovered keypair as the
    [BUFFER_SIGNER] to `solana program deploy` or `solana write-buffer'.
    Or to recover the account's lamports, pass it as the
    [BUFFER_ACCOUNT_ADDRESS] argument to `solana program close`.
    =================================================================================
    

    First recover the keypair from the seed phrase that it gave you:

    # After running this, paste in the seed phrase above
    solana-keygen recover -o recover.json
    

    Then you can close the account to recover your SOL.

    solana program close recover.json
    

    To recover SOL from ALL in-progress or failed deployments

    Alternatively, you can recover the SOL from all in-progress deployments by running:

    solana program close --buffers