Libraries
Libraries are similar to contracts, but they are deployed just once at a specific address and their code is reused by various contracts. This means that if library functions are called, their code is executed in the context of the calling contract; So, this
points to the calling contract, and specifically, allows access to the storage from the calling contract. As a library is an isolated piece of source code, it can only access state variables of the calling contract if they are explicitly supplied (it would have no way to name them otherwise).
Libraries can contain structs and enums, but they cannot have state variables. They don't support inheritance and they cannot receive Ethereum.Â
Once a Solidity library is deployed to the blockchain, it can be used by anyone, assuming one knows its address and has the source code (with only prototypes or complete implementation). The source code is required by the Solidity compiler so it can ensure that the methods being accessed actually...