🇵🇹
DAO Lunes Labs - PT
  • 👋Seja Bem-vindo a DAO Lunes Labs
  • Overview
    • 🚪Introdução
    • 🚀Manifesto DAO Lunes Labs
    • 🍕Tokenomics
    • 👑Proposta de Valor
    • 🧑‍🚀Comunidade e Participação
    • 🗺️Roadmap
    • 💼Compromisso com Ética e Responsabilidade
    • 👾Programa de Bug Bounty: Lunes Security Initiative (LSI)
  • Developers
    • 💽Para Nodes
      • 🥾Instalar Node
        • 🏗️Rust toolchain
        • 🐧Linux
    • 🖥️Para Desenvolvedores
      • 📑Smart Contract Ink! 4.x
        • ✨Configuração
          • 📐Criando um projeto com ink!
          • 🖥️Compile Seu Contrato
          • ⛓️Executar um nó Lunes
          • ⬆️Implante seu contrato
          • 🔛Chame Seu Contrato
          • 🛠️Solução de problemas
        • 🪄Fundamentos
          • 👾Modelo de Contrato
          • 👨‍🚀Armazenando Valores
          • 🔭Lendo Valores do Armazenamento
          • 🦸‍♂️Alterando os Valores de Armazenamento
          • 🎡Eventos
          • 👨‍🔧Seletores
          • 🪶Definições de Trait
          • 🗣️Chamadas entre Contratos (Cross-Contract Calls)
          • 🦸Contratos Atualizáveis
          • 🤺Funções do Ambiente
          • 🏟️Tipos de Ambiente de Cadeia
          • 💠Metadados
          • 🧪Testes de Contrato
          • 🕵️‍♂️Depuração de Contratos
          • 🔬Verificação de Contrato
        • 🎙️Macros e Atributos
          • 📇#[ink::contract]
          • 👽#[ink(anonymous)]
          • 👷#[ink(constructor)]
          • 📏#[ink(default)]
          • 🎢#[ink(event)]
          • 🛩️#[ink(impl)]
          • 📧#[ink(message)]
          • 👨‍💼#[ink(namespace = "…")]
          • 💸#[ink(payable)]
          • ⚡#[ink(selector = S:u32)]
          • 💽#[ink(storage)]
          • 💣#[ink(topic)]
          • ⛓️#[ink::chain_extension]
        • 💽Storege & Data Structires
          • Working with Mapping
          • Storage Layout
          • Custom Data Structures
          • Metadata Format
        • 👾Frontend Development
          • Getting Started
          • Connect Wallet
          • Hooks
            • All Hooks
            • Contracts
              • useCall
              • useCallSubscription
              • useContract
              • useDryRun
              • useEventSubscription
              • useEvents
              • useTx
              • useTxPaymentInfo
            • Wallets
              • useWallet
              • useAllWallets
              • useInstalledWallets
              • useUninstalledWallets
            • API
              • useApi
              • useBalance
              • useBlockHeader
          • Configuration
          • useink / core
            • Contracts
              • Call
              • decodeCallResult
              • decodeError
              • getRegistryError
              • toAbiMessage
          • useink / chains
            • Getting Started
            • Chain Configurations
            • ChainId
          • useink / notifications
            • Getting Started
            • Configuration
            • useNotifications
            • toNotificationLevel
          • useink / utils
            • Getting Started
            • Pick Helpers
            • tx Helpers
            • Types
        • 💡Examples
          • 📔Smart Contracts
          • 📱Dapps
        • 🛠️Tools
          • 🖌️OpenBrush
      • 📒Smart Contract - EVM
        • Create ERC-20 Ink Token!
      • 💰Desenvolvendo uma Wallet Lunes
        • 👾Transações de Tokens PSP22
    • 🎨Para Designers
      • 🖌️Brand Lunes
Powered by GitBook
On this page
  • Typechain-Polkadot​
  • Sol2Ink​

Was this helpful?

  1. Developers
  2. Para Desenvolvedores
  3. Smart Contract Ink! 4.x
  4. Tools

OpenBrush

Last updated 1 year ago

Was this helpful?

is a library for smart contract development on ink! maintained by the team.

It provides standard contracts based on , as well as higher-level contracts and Rust macros that generate ink! code.

Using OpenBrush is simple, you only add the dependency to your Cargo.toml file. You can find an example .

Which standards and contract components does it contain?

  • PSP22: Fungible Token (ERC20 equivalent) with extensions.

  • PSP34: Non-Fungible Token (ERC721 equivalent) with extensions.

  • PSP37: ERC1155 equivalent with extensions.

  • Ownable Restrict access to action for non-owners.

  • Access Control: Define a set of roles and restrict access to an action by roles.

  • Reentrancy Guard: Prevent reentrant calls to a function.

  • Pausable: Pause/Unpause the contract to disable/enable some operations.

  • Timelock Controller: Execute transactions with some delay.

  • Payment Splitter: Split the amount of native tokens between participants.

Generic Trait Implementation

OpenBrush adds support for generic Trait implementations, so that you can split a Trait and its implementation into different files. This can increase the readability and maintainability of your smart-contract code base ().

Wrapper around Traits: #[openbrush::wrapper]

If you know that the other contract implements a trait and the trait is attributed with #[openbrush::trait_definition] you only need that trait definition and the address of the other contract in order to call a method from the deployed third-party contract. The wrapper is an attribute macro named #[openbrush::wrapper] for traits. It will generate a callable structure of the other contract with the name defined by a user:

// You can create wrapper in the place where you defined the trait
// Or if you import **everything** from the file where you define trait
#[openbrush::wrapper]
type Trait1Ref = dyn Trait1;

The benefits of such mechanism is a functional polymorphism. Instead of working with the concrete implementation of the trait as a dependency in you contract, you only interact with its interface. That means that you do not need to import other contracts as dependencies to the calling contract. If you need to update the implementation of the trait within the calling contract, you only need to replace the called contract address. The wrapper does not guarantee that the given address refers to a contract that implements the given trait.

Additionally, the wrapper supports multiple traits (i.e. dyn Erc20 + Ownable + Erc721) without losing the syntax highlighting from your favourite IDE.

See for more information.

Documentation

Typechain-Polkadot

Another tool helpful for ink! smart contracts development is .

Typechain-Polkadot is used to generate Typescript wrappers around your smart contract. This can be used for UI development or in integration tests of your ink! smart contracts. The library uses under the hood, but is especially useful because all calls and queries are typed, therefore the chance of getting some error during a call is mitigated.

Sol2Ink

is a tool which can support migrations from Solidity to ink!. Solidity code is passed to Sol2Ink and converted to an ink! contract. The tool can also be used to learn the differences between Solidity and ink! code.

Questions?

If you have any questions about how to use any of these tools, or just about the ink! smart contracts in general, you can join the or ask a question on the .

🖥️
📑
🛠️
🖌️
OpenBrush
Brushfam
Polkadot Standard Proposals (PSPs)
here
​
​
detailed description
​
this example
​
OpenBrush Github repo
Official Docs
OpenBrush website
Substrate Seminar (Youtube)
How to use modifiers
​
Typechain-Polkadot
polkadot-js/api
​
Sol2Ink
​
Brushfam element channel
Substrate Stack Exchange