docs
docs copied to clipboard
Enhance Smart Contract Upgradability Documentation: Addressing Field Changes and Migration
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:
- 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
}
- 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>
}