2

I have created and written a simple Solana program using anchor & successfully compiled it using anchor build command. I run a local validator node in a terminal using solana-test-validator and then try to deploy my program using anchor deploy in a separate terminal I get this error:

Error: Account allocation failed: RPC response error -32002: 
Transaction simulation failed: This account may not be used to pay transaction fees 
There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.

I have checked that the account that I was using to deploy the program has sufficient lamports. Eventually, I generated a new keypair using solana-keygen new -o, airdropped sol to it and then used this account to deploy using anchor deploy --provider.wallet and it deployed successfully. Still i am not clear though why my default solana-cli wallet was not able to deploy the account. error output my Anchor.toml file: Anchor.toml file

2 Answers 2

2

This error usually comes when the wallet is not owned by System Program. Can you visit Solana Explorer, switch the cluster to the localnet and search for your address?

It should look like this: Data Size = 0

Data Size = 0 byte and Assigned Program Id = System Program.

If you are seeing something like this: Data Size = 4012

Data Size != 0 and Assigned Program Id != System Program then probably you mistakenly transferred the ownership of your wallet to some custom program and it can no longer be used to deploy the program unless you reset the local validator.

2
  • Yes, u r correct. I checked the account info using "solana account" command, and the owner is indeed some other program & it also has some data in it. Commented Nov 10, 2022 at 9:41
  • @ShubhamSingh I noticed this answer was at zero. If you did upvote it nevermind (someone down voted it) but if it helped you, you should upvote it! I upvoted it just now because it helped me.
    – mikemaccana
    Commented Jun 4, 2023 at 20:42
2

you probably need to check the workspace configuration, in the Anchor.toml file in the project root, you should have something like:

[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"

be aware that if you run anchor deploy you're using those parameters. If you want to be sure what you're doing, you can overwrite those params with the command:

anchor deploy -p your-program --provider.cluster l --provider.wallet ~/path/to/authority.json

where:

  • -p your-program is the program name
  • --provider.cluster l is the selected cluster, l stands for localnet
  • --provider.wallet ~/path/to/authority.json is the wallet paying for the deploy and the upgrade authority of the program

for the latest point be aware that:

  1. the wallet needs enough SOL to deploy the program
  2. if the program has already been deployed with a different upgrade authority you can upgrade it with a new binary
1
  • I have checked my Anchor.toml file. Everything seems to be fine there: [features] seeds = false skip-lint = false [programs.localnet] flipper = "ExxosCX1gHbPh4TnAN2MgSfKDxZKzxTYvpeiVgcjvVsC" [registry] url = "api.apr.dev" [provider] cluster = "localnet" wallet = "/home/shubh/.config/solana/id.json" [scripts] test = "yarn run mocha -t 1000000 tests/" Commented Nov 4, 2022 at 12:24

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.