# #\[ink(payable)]

Aplicável a mensagens ink!.&#x20;

Permite receber um valor como parte da chamada da mensagem ink!. Os construtores ink! são implicitamente pagáveis devido ao endosso inicial necessário para um contrato.&#x20;

Uma mensagem ink! por padrão rejeitará chamadas que adicionem fundos adicionais ao contrato inteligente. Os autores de contratos inteligentes ink! podem tornar uma mensagem ink! pagável adicionando a marcação de pagável a ela. Um exemplo abaixo:&#x20;

Observe que os construtores ink! são sempre implicitamente pagáveis e, portanto, não podem ser marcados como tal.

```rust
#[ink::contract]
mod flipper {

    #[ink(storage)]
    pub struct Flipper {
        value: bool,
    }

    impl Flipper {
        #[ink(constructor)]
        pub fn new(initial_value: bool) -> Self {
            Flipper { value: false }
        }

        /// Flips the current value.
        #[ink(message)]
        #[ink(payable)] // You can either specify payable out-of-line.
        pub fn flip(&mut self) {
            self.value = !self.value;
        }

        /// Returns the current value.
        #[ink(message, payable)] // or specify payable inline.
        pub fn get(&self) -> bool {
            self.value
        }
    }
}
```

### Exemplo[​](https://use.ink/macros-attributes/payable#example) <a href="#example" id="example"></a>

```rust
#[ink(message, payable)]
pub fn pay_me(&self) {
    let _transferred = self.env().transferred_balance();
}
```

Consulte o contrato [examples/contract-transfer](https://github.com/paritytech/ink-examples/blob/main/contract-transfer/lib.rs) para um exemplo mais abrangente em Rust.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lunes-labs.gitbook.io/dao-lunes-labs-pt/developers/para-desenvolvedores/smart-contract-ink-4.x/macros-e-atributos/ink-payable.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
