Web3 Dictionary Logo
Web3 Dictionary
Contribute

Categories

AllBlockchainDappsDAOsDeFiNFTsRegulationSecuritySmart ContractsTokenomicsWalletsWeb3 GamingOthers
  1. Web3 Dictionary
  2. Smart Contracts
  3. Library
Smart Contracts

Library

Reusable smart contract code that other contracts can call to perform specific functions.

Last Updated

2026-03-19

Related Concepts

Smart ContractSolidityBytecodeContract Call
Web3-Explorer Logo

Scale Blockchain Infra

AD

Smart contracts, protocol integrations, and scalable architecture for high-performance Web3 products.

See Blockchain Services

What is Library?

A library is reusable smart contract code that provides utility functions without storing state. Libraries are toolkits commonly needed functionality that multiple contracts can share.

How does Library work?

  1. A developer writes a stateless library contract.
  2. Other contracts import and call its functions.
  3. Libraries can be embedded directly into the contract bytecode (internal) or deployed separately and referenced (external).

Why does Library matter?

Libraries enable code reuse and security. Without them, every contract would reimplement basic functions like safe math or access control, increasing both code size and audit surface.

Key features of Library

  • Stateless no data storage
  • Importable by multiple contracts
  • Reduces code duplication
  • Often open-source and publicly audited

Examples of Library

SafeMath prevents integer overflow bugs contracts call SafeMath.add(a, b) instead of a + b .

OpenZeppelin's AccessControl provides role-based permissions used across hundreds of DeFi protocols.

External References

  • Solidity Libraries
  • Solidity Libraries (Ethereum.org)