How do I deploy a program to Solana - Solana/Rust

Viewed 1168

I am attempting to run the HelloWorld solana program. I have cloned this repo. I have started the project with

solana-test-validator

I ran npm install and then was able to build the rust project with

npm run build:program-rust

I can see the .so file in the directory /dist/program/helloworld.so. When I try to deploy the program to solana, I run

solana program deploy dist/program/helloworld.so

And here is the error I get

Error: Dynamic program error: No such file or directory (os error 2)

It can't find the file, but I have verified it is there. I have tried the full path and get the same error. I have tried to clean and reinstall the libs, but it hasn't helped.

What else should I try?

3 Answers

A couple things to make sure of:

  1. The localhost (as opposed to devnet) is set via solana config set --url localhost
  2. You have generated a new keypair solana-keygen new

Besides the specific advises stated in the other answer, it might be also helpful to try Solana Playground (beta) browser based Solana IDE. It makes entire process way smoother.

Features:

  • New Project (Native, Anchor, Seahorse/Python)
  • Auto airdrop
  • Basic editing
  • Import/Export
  • Build
  • Deployment
  • Embedded wallet (or you can also use Phantom)
  • Network settings

Hope you find it handy!

Remember to create a new solana keygen and use solana config get to check your config file. (Optional) You can use solana-keygen pubkey and solana-keygen verify to check your wallet. Set the keypair if the location of the keygen is incorrect. Set the deployed url to devnet. Airdrop 2 sol to your wallet. Use solana balance to check whether the config keypair/wallet is correct.

  1. solana-keygen new --outfile /root/solana/my_wallet.json
  2. solana config get
  3. solana config set --keypair
  4. solana config set --url https://api.devnet.solana.com
  5. solana airdrop 2
  6. solana balance (address)

Hope this can help you in config your file.

Related