# Method Types

#### Payable Methods&#x20;

* Methods can be annotated with `#[payable]` to allow tokens to be transferred with the method invocation.&#x20;

```rust
#[payable]
pub fn my_method(&mut self) {
...
}
```

#### Private Methods&#x20;

* Some methods need to be exposed to allow the contract to call a method on itself through a promise, but want to disallow any other contract to call it. For this, use the `#[private]` annotation to panic when this method is called externally.

```rust
#[private]
pub fn my_method(&mut self) {
...
}
```

#### Difference between pub fn and fn&#x20;

`pub fn` will be exported from the WASM so they can be called as part of a transaction. Otherwise it's just a helper function and not an entry point

#### Difference between private functions and fn&#x20;

`#[private]` is a special marker that's part of the `#[near_bindgen]` macro. You attach it to public functions, and it adds a restriction such that only the contract itself is allowed to call that function as part of a transaction, even though the function is public. `#[private]` technically creates a public entry point which only the contract itself is allowed to call. Useful for callbacks.


---

# 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://thryec.gitbook.io/dev-compedium/near/rust-contracts/method-types.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.
