Last active
February 14, 2024 09:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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