Search⌘ K
AI Features

Libraries

Explore how Solidity libraries enable reusable and stateless functions that improve modularity and efficiency in smart contracts. Understand their key features, restrictions, and how to integrate them properly using examples. Learn best practices to design libraries that keep contracts lean and maintainable.

Solidity libraries are reusable components that contain functions that can be accessed by other contracts. Libraries, like contracts, are primarily intended for reuse. Solidity libraries are distinguished by certain requirements and features that ensure their proper use inside the Ethereum ecosystem.

Key features of Solidity libraries

Here are the key features of Solidity libraries:

  • Direct invocation of stateless functions: Library functions that don’t alter the system’s state can be directly invoked. Only pure or view functions from the library can be called externally.

  • Immutable and stateless nature: Libraries are considered stateless, and once deployed, they can’t be destroyed. Their immutability ensures consistency and reliability in ...