Anchor for EVM Developers
  • Anchor for EVM Developers
  • Program Address
  • Functions
  • Token
  • Validation
  • Mutation
  • Calling Other Contract
  • Wrap Native Token
  • Transfer Native Token
  • Transfer Fungible Token
  • Deploy A Fungible Token
  • Access Control
  • Address Mining
  • Events
  • Forking Mainnet
  • Function Selector
  • Feature Flags
  • Feature Dependencies
  • Migration / Scripts
  • Upgrade Programs
  • Block timestamp
Powered by GitBook
On this page

Upgrade Programs

PreviousMigration / ScriptsNextBlock timestamp

Last updated 1 month ago

EVM

Solana

If the new program's size is greater than the current program's size, the program account's size has to be extended before the upgrade

CURRENT_PROGRAM_SIZE=`solana program show $PROGRAM_ADDRESS --output json | jq .dataLen`
NEW_PROGRAM_SIZE=`ls -la target/deploy/program.so | awk '{print $5}'`

DIFFERENCE=$((NEW_PROGRAM_SIZE - CURRENT_PROGRAM_SIZE))
solana program extend $PROGRAM_ADDRESS $DIFFERENCE
anchor upgrade --program-id $PROGRAM_ADDRESS 

Example from Cyfrin