docs icon indicating copy to clipboard operation
docs copied to clipboard

Enhance Smart Contract Upgradability Documentation: Addressing Field Changes and Migration

Open sczembor opened this issue 11 months ago • 0 comments

The current section on smart contract upgradability in the documentation contains information on adding new functions. However, it is missing any info regarding the following:

  1. Adding New Fields: How can developers incorporate new fields (storage variables) into an existing smart contract after deployment?
struct contract {
   users: Vec<address>,
}

migrate to ↓

struct contract {
   users: Vec<address>,
   funds: Vec<u64>, // new field
}
  1. Migrating Existing Fields: In scenarios where modifications are required to existing fields (e.g., changing data types, renaming)
struct contract {
   users: Vec<address>,
   funds: Vec<u64>,
}

migrate to ↓

struct contract {
   user_funds: Map<address, u64>
}

sczembor avatar Mar 06 '24 14:03 sczembor