Skip to content

Commit

Permalink
Sway Reference: Section 9 Annotations. Document the payable annotation (
Browse files Browse the repository at this point in the history
  • Loading branch information
Braqzen authored Jun 2, 2023
1 parent 545d7c4 commit 6a9ba1e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reference/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- [Types](./documentation/language/annotations/type.md)
- [Attributes](./documentation/language/annotations/attributes/index.md)
- [Storage](./documentation/language/annotations/attributes/storage.md)
- [Payable](./documentation/language/annotations/attributes/payable.md)
- [Test](./documentation/language/annotations/attributes/test.md)
- [Traits](./documentation/language/traits/index.md)
- [Generics](./documentation/language/generics/index.md)
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/src/code/language/annotations/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ fn example() {
let baz: bool = true;
// ANCHOR_END: example
}

abi MyContract {
// ANCHOR: payable
#[payable]
fn deposit();
// ANCHOR_END: payable
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Payable

The payable annotation is used to allow a [contract](../../program-types/contract.md) [function](../../functions/index.md) to accept an asset forwarded via a call.

## Usage

To allow a [contract](../../program-types/contract.md) to accept assets we use the `payable` keyword.

```sway
{{#include ../../../../code/language/annotations/src/main.sw:payable}}
```

0 comments on commit 6a9ba1e

Please sign in to comment.