Skip to content

🎁 [Feature Request]: feature flags to reduce compiled contract size #522

@brozorec

Description

@brozorec

What is the feature you would like to see?

Introduce feature flags in stellar-tokens, stellar-access, and stellar-contract-utils to allow developers to compile only the modules they need, reducing final contract binary size.

Motivation

When we consolidated ~17 separate crates into grouped modules, we optimized for developer experience but increased contract sizes. For example, stellar-tokens now includes code for fungible, non-fungible, vaults, and RWAs even if a project only needs one.

Proposed Solution

Add Cargo feature flags to the following crates:

  1. stellar-tokens
  • fungible
  • non-fungible
  • vaults
  • rwa
  1. stellar-access
  • ownable
  • roles
  1. stellar-contract-utils
  • crypto
  • math
  • merkle-distributor
  • pausable
  • upgradeable

Usage Example

[dependencies]
stellar-tokens = { version = "x.y.z", default-features = false, features = ["non-fungible"] }

Additional Considerations

  • Decide on default features (for backward compatibility?)
  • Update documentation with feature flag usage
  • Consider inter-crate dependencies (e.g. if rwa depends on fungible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions