Skip to content

Instantly share code, notes, and snippets.

@ochaloup
Last active February 14, 2024 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochaloup/e013a7912858818ad2855e13754edf36 to your computer and use it in GitHub Desktop.
Save ochaloup/e013a7912858818ad2855e13754edf36 to your computer and use it in GitHub Desktop.
Snippet of Solana Anchor CLI IDL manipulation when IDL account is managed under multisig
# https://gist.github.com/ochaloup/e013a7912858818ad2855e13754edf36
# get IDL account address
solana find-program-derived-address <PROGRAM_ID_PUBKEY>
solana create-address-with-seed --from <DERIVED_ADDRESS> 'anchor:idl' <PROGRAM_ID_PUBKEY>
# initialize anchor IDL account with wallet as authority
anchor idl init --provider.cluster mainnet \
--provider.wallet path/to/wallet.json \
--filepath ./target/idl/<some-anchor-program>.json \
<PROGRAM_ID_PUBKEY>
# change IDL authority to multisig public key
anchor idl set-authority --provider.cluster mainnet \
--provider.wallet path/to/wallet.json \
--program-id <PROGRAM_ID_PUBKEY> \
--new-authority <MULTISIG_PUBKEY>
# IDL upgrade is needed?
anchor idl write-buffer --provider.cluster mainnet \
--filepath target/idl/<some-anchor-program>.json \
<PROGRAM_ID_PUBKEY>
# -> Idl buffer created: <BUFFER_ID>
# change authority of the IDL buffer to multisig pubkey
anchor idl set-authority --provider.cluster mainnet \
--new-authority <MULTISIG_PUBKEY> \
--program-id <PROGRAM_ID_PUBKEY> \
<BUFFER_ID>
# generate base64 format transaction
# the authority pubkey that has to sign is found from program data from chain
anchor idl --provider.cluster mainnet \
set-buffer --buffer <BUFFER_ID> \
<PROGRAM_ID_PUBKEY> \
--print-only
# base64 instruction can be plugged as an instruction in the multisig program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment