Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openzeppelin/contracts-upgradeable

Package Overview
Dependencies
Maintainers
4
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openzeppelin/contracts-upgradeable

Secure Smart Contract library for Solidity

  • 5.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
142K
decreased by-37.13%
Maintainers
4
Weekly downloads
 
Created

What is @openzeppelin/contracts-upgradeable?

@openzeppelin/contracts-upgradeable is a library for secure smart contract development. It provides reusable and upgradeable smart contract components that follow best practices in security and gas efficiency. The package is particularly useful for creating upgradeable smart contracts, which can be modified after deployment without changing their address.

What are @openzeppelin/contracts-upgradeable's main functionalities?

Upgradeable Contracts

This feature allows you to create upgradeable contracts using the Initializable base contract. The `initialize` function is used instead of a constructor to set initial values.

```json
{
  "code": "import { Initializable } from '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';\n\ncontract MyContract is Initializable {\n    uint256 public value;\n\n    function initialize(uint256 _value) public initializer {\n        value = _value;\n    }\n}"}
```

Access Control

This feature provides role-based access control mechanisms. The `AccessControlUpgradeable` contract allows you to define roles and restrict access to certain functions based on these roles.

```json
{
  "code": "import { AccessControlUpgradeable } from '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';\n\ncontract MyAccessControl is Initializable, AccessControlUpgradeable {\n    bytes32 public constant ADMIN_ROLE = keccak256('ADMIN_ROLE');\n\n    function initialize(address admin) public initializer {\n        _setupRole(ADMIN_ROLE, admin);\n    }\n}"}
```

ERC20 Token

This feature allows you to create upgradeable ERC20 tokens. The `ERC20Upgradeable` contract provides the standard ERC20 functionality, and the `initialize` function sets the token's name and symbol.

```json
{
  "code": "import { ERC20Upgradeable } from '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol';\n\ncontract MyToken is Initializable, ERC20Upgradeable {\n    function initialize(string memory name, string memory symbol) public initializer {\n        __ERC20_init(name, symbol);\n    }\n}"}
```

Other packages similar to @openzeppelin/contracts-upgradeable

Keywords

FAQs

Package last updated on 17 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc