3

I'm looking to deploy a regular solana program written in Rust (not anchor) on mainnet. For some reason I can't rewrite it using anchor solana. I have searched online and all failed. Does anyone know the detailed answer?

1
  • 1
    I'd advice patience. This might be unrelated to your program as mainnet isn't currently active for user transactions
    – Ademola
    Feb 25, 2023 at 19:37

2 Answers 2

3

You use cargo build-sbf or cargo build-bpf (depending on you used version) to build your program. That will build a .so file in your target/deploy directory. From there you can use the solana program deploy command to deploy your program. To see relevant info about that run solana program deploy --help.

0
  1. Run cargo build-sbf or cargo build-bpf (depending on version) to build your program. That will build a .so file in target/deploy directory.

  2. To deploy on mainnet, you need a wallet containing real SOL. Copy wallet private key

and paste it in the javascript code below

const bs58 = require('bs58')
const fs = require('fs')
b = bs58.decode(
    'your private key'
)
j = new Uint8Array(
    b.buffer,
    b.byteOffset,
    b.byteLength / Uint8Array.BYTES_PER_ELEMENT
)
fs.writeFileSync('key.json', `[${j}]`)

  1. Try run above code to create key.json file

  2. Run solana config set --url https://api.mainnet-beta.solana.com

  3. Run solana program deploy -k *path_to_key.json* *path_to_.so_file*

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.