2

I have created a simple counter smart contract with anchor. I followed all steps outlined in this answer: https://stackoverflow.com/a/73862346/1192872

When I deploy my code to the solana devnet the deployment is stuck in a loop: Deployment loop

If it is helpful, here is my code

use anchor_lang::prelude::*;

declare_id!("2QmXMXyMAmZCE92Uqm2YhKgpqH3Teo6vZDNg7CRHYCK7");

#[program]
pub mod counter_program {
    use super::*;

    pub fn create(ctx: Context<Create>) -> Result<()> {
        ctx.accounts.counter.authority = ctx.accounts.authority.key();
        ctx.accounts.counter.count = 0;

        Ok(())
    }

    pub fn increment(ctx: Context<Increment>) -> Result<()> {
        ctx.accounts.counter.count += 1;
        Ok(())
    }

    pub fn decrement(ctx: Context<Increment>) -> Result<()> {
        ctx.accounts.counter.count -= 1;
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Increment<'info> {
    #[account(mut, has_one = authority)]
    pub counter: Account<'info, Counter>,
    pub authority: Signer<'info>,
}

#[derive(Accounts)]
pub struct Create<'info> {
    #[account(init, payer = authority, space = 8 + 40)]
    pub counter: Account<'info, Counter>,
    #[account(mut)]
    pub authority: Signer<'info>,
    pub system_program: Program<'info, System>
}

#[account]
pub struct Counter {
    pub authority: Pubkey,
    pub count: u64,
}
Yggdrasil
  • 1,377
  • 2
  • 13
  • 27

1 Answers1

1

This is likely due to an old version of the Solana CLI. I was able to reproduce this using version 1.10.40.

Devnet was just upgraded to 1.14, so you need to update your CLI to at least 1.13, but I'd recommend 1.14:

$ solana-install init 1.14.17
Jon C
  • 7,019
  • 10
  • 17
  • This was the correct direction. Was facing the same issue and ran `sh -c "$(curl -sSfL https://release.solana.com/v1.15.2/install)" downloading v1.15.2 installer ✨ 1.15.2 initialized` after which it started to work. – Rahul Apr 16 '23 at 20:37