I'm trying to deploy my Solana program to mainnet using anchor deploy --provider.cluster mainnet. When I first ran this command I got an insufficient funds error and it told me that I needed around 1.6 SOL in the program account. Just to be safe I sent 1.9 SOL to the pubkey that was output when it gave me the error. After I funded the account I tried deploying again with the same command and I got the error: Deploying program failed: Error processing Instruction 1: custom program error: 0x1. Then I tried to recover my funds so that I could deploy again. I recovered the keypair and then I tried running the same command again.

This time I got this in the console:

Deploying workspace: https://api.mainnet-beta.solana.com
Upgrade authority: /Users/dylanmolina/.config/solana/id.json
Error: expected !

I know that this error usually means that there's some sort of syntax error in the command but I believe that it's correct: anchor deploy --provider.cluster mainnet

Is there something else that may be causing this? Should I have more SOL in my program balance(currently at ~3.99 SOL)? Is this a syntax error? Faulty program? Any help would be appreciated here, thanks!

For reference:


seeds = false
skip-lint = false
artsolbackend = "8oMdunAFJKYeLDwHa2KrhyNGvbLqk4uB3iC6g4nifuCm"

url = "https://api.apr.dev"

cluster = "devnet"
wallet = "/Users/dylanmolina/.config/solana/id.json"

test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"


use anchor_lang::prelude::*;
use anchor_lang::solana_program::entrypoint::ProgramResult; //ProgramResult


pub mod artsolbackend {
    use super::*;

    pub fn submit_post(ctx: Context<SubmitPost>, title: String, description: String, artwork: String, cta: String) -> Result<()> {
        let post: &mut Account<Post> = &mut ctx.accounts.post;
        let creator: &Signer = &ctx.accounts.creator;

        if title.chars().count() > 50 {
            return Err(error!(ErrorCode::TitleTooLong));

        if description.chars().count() > 280 {
            return Err(error!(ErrorCode::DescriptionTooLong));

        if cta.chars().count() > 150 {
            return Err(error!(ErrorCode::CTATooLong));

        post.creator = *creator.key;
        post.title = title;
        post.description = description;
        post.artwork = artwork;
        post.cta = cta;

    pub fn send_sol(ctx: Context<SendSol>, amount: u64) -> ProgramResult {
        let ix = anchor_lang::solana_program::system_instruction::transfer(

pub struct SendSol<'info> {
    /// CHECK: This is not dangerous because we don't read or write from this account
    from: Signer<'info>,
    /// CHECK: This is not dangerous because we don't read or write from this account
    to: AccountInfo<'info>,
    /// CHECK: This is not dangerous because we don't read or write from this account
    system_program: Program<'info, System>,

pub struct SubmitPost<'info> {
    #[account(init, payer = creator, space = Post::LEN)]
    pub post: Account<'info, Post>,
    pub creator: Signer<'info>,
    pub system_program: Program<'info, System>,

pub struct Post {
    pub creator: Pubkey,
    pub title: String,
    pub description: String,
    pub artwork: String,
    pub points: i64,
    pub stars: u64,
    pub cta: String,

const DISCRIMINATOR_LENGTH: usize = 8;

const PUBLIC_KEY_LENGTH: usize = 32;

//String Prefix
const STRING_LENGTH_PREFIX: usize = 4;

const MAX_TITLE_LENGTH: usize = 50 * 4;

const MAX_DESCRIPTION_LENGTH: usize = 280 * 4;

const MAX_ARTWORK_LENGTH: usize = 100 * 4;

//Points & Stars
const INT_SIZE: usize = 8;

const MAX_CTA_LENGTH: usize = 150 * 4;

impl Post {
    const LEN: usize = DISCRIMINATOR_LENGTH 
    + PUBLIC_KEY_LENGTH  //Creator
    + INT_SIZE //Points
    + INT_SIZE //Stars

pub enum ErrorCode {
    #[msg("The provided title should be 50 characters maximum!")]

    #[msg("The provided description should be 280 characters maximum!")]

    #[msg("The provided artwork file should have a link that's 100 characters maximum!")]

    #[msg("The provided CTA link shouls be a maximum of 150 characters!")]

1 Answer 1


Trying to make some informed guesses here.

You have cluster = "devnet" in your Anchor.toml. I recommend setting it to mainnet while deploying to mainnet.

I also recommend setting the cluster to mainnet in the command line, as in solana config set -u m.

That will then save you the --provider.cluster mainnet, and you can just issue a plain anchor deploy.

The funds will be deducted from the wallet that's set as update authority, in your case /Users/dylanmolina/.config/solana/id.json. No need to transfer anything.

In my case it was 8 SOL, so be sure to have enough funds in your wallet.

When you later close the account (i.e. un-deploy your program), you will get your deposit back.

  • Thanks for the answer it really moved me forward. Now I'm using solana program deploy instead of anchor deploy because I need to recover the funds to continue the deployment. However, after passing in all the args and using the correct flags(it seems), I'm getting this error: Initial deployments require a keypair be provided for the program id. Right now I'm just passing in the program id that I declared in lib.rs after the --program-id flag but I'm not sure if I need to use the entire keypair or how to even get it. Commented Aug 17, 2022 at 0:39
  • 2
    please post a new question instead of starting an unrelated conversation in the comments
    – trent.sol
    Commented Aug 17, 2022 at 1:52

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.