index.adoc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. = Getting Started
  2. *OpenZeppelin is a library for secure smart contract development.* It provides implementations of standards like ERC20 and ERC721 which you can deploy as-is or extend to suit your needs, as well as Solidity components to build custom contracts and more complex decentralized systems.
  3. [[install]]
  4. == Install
  5. OpenZeppelin should be installed directly into your existing node.js project with `npm install @openzeppelin/contracts`. We will use https://truffleframework.com/truffle[Truffle], an Ethereum development environment, to get started.
  6. Please install Truffle and initialize your project:
  7. [source,sh]
  8. ----
  9. $ mkdir myproject
  10. $ cd myproject
  11. $ npm init -y
  12. $ npm install truffle
  13. $ npx truffle init
  14. ----
  15. To install the OpenZeppelin library, run the following in your Solidity project root directory:
  16. [source,sh]
  17. ----
  18. $ npm install @openzeppelin/contracts
  19. ----
  20. NOTE: OpenZeppelin features a stable API, which means your contracts won't break unexpectedly when upgrading to a newer minor version. You can read ṫhe details in our xref:api-stability.adoc[API Stability] document.
  21. [[usage]]
  22. == Usage
  23. Once installed, you can start using the contracts in the library by importing them:
  24. [source,solidity]
  25. ----
  26. pragma solidity ^0.5.0;
  27. import "@openzeppelin/contracts/ownership/Ownable.sol";
  28. contract MyContract is Ownable {
  29. ...
  30. }
  31. ----
  32. Truffle and other Ethereum development toolkits will automatically detect the installed library, and compile the imported contracts.
  33. IMPORTANT: You should always use the installed code as-is, and neither copy-paste it from online sources, nor modify it yourself.
  34. [[next-steps]]
  35. == Next Steps
  36. Check out the the guides in the sidebar to learn about different concepts, and how to use the contracts that OpenZeppelin provides.
  37. * xref:access-control.adoc[Learn about Access Control]
  38. * xref:crowdsales.adoc[Learn about Crowdsales]
  39. * xref:tokens.adoc[Learn about Tokens]
  40. * xref:utilities.adoc[Learn about our Utilities]
  41. OpenZeppelin's xref:api:token/ERC20.adoc[full API] is also thoroughly documented, and serves as a great reference when developing your smart contract application.
  42. Additionally, you can also ask for help or follow OpenZeppelin's development in the https://forum.openzeppelin.com[community forum].
  43. Finally, you may want to take a look at the guides on our blog, which cover several common use cases and good practices: https://blog.openzeppelin.com/guides. The following articles provide great background reading, though please note, some of the referenced tools have changed as the tooling in the ecosystem continues to rapidly evolve.
  44. * https://blog.openzeppelin.com/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05[The Hitchhiker’s Guide to Smart Contracts in Ethereum] will help you get an overview of the various tools available for smart contract development, and help you set up your environment
  45. * https://blog.openzeppelin.com/a-gentle-introduction-to-ethereum-programming-part-1-783cc7796094[A Gentle Introduction to Ethereum Programming, Part 1] provides very useful information on an introductory level, including many basic concepts from the Ethereum platform
  46. * For a more in-depth dive, you may read the guide https://blog.openzeppelin.com/designing-the-architecture-for-your-ethereum-application-9cec086f8317[Designing the architecture for your Ethereum application], which discusses how to better structure your application and its relationship to the real world