Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/build/guides/auth/contract-authorization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ To illustrate how to add authorization to a simple cross-contract invocation, we

The invoking contract in the mentioned example contract creates a client for invoking the `add()` function in the addition contract. Let’s say we want the `add()` contract to be authorized by a user. Then, we need to pass the user to the `add()` contract function from the invoking function.

Even though the invoking function may not require the user’s authorization, the `add()` function will panic if it encounters authorization not tied to the root/top contract invocation. Therefore, we need to use `require_auth()` on the user in the invoking function.
Even though the invoking function may not require the user’s authorization, it's recommended to authorize the user at the entry point. Without that, the authorized inner `add()` call can be front-run by anyone without being wrapped in `add_with()`. Adding `require_auth()` at the entry point ensures that all the inner contract calls that are authorized on behalf of user will be executed atomically together with the entry point call. Therefore, we need to use `require_auth()` on the user in the invoking function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Even though the invoking function may not require the user’s authorization, it's recommended to authorize the user at the entry point. Without that, the authorized inner `add()` call can be front-run by anyone without being wrapped in `add_with()`. Adding `require_auth()` at the entry point ensures that all the inner contract calls that are authorized on behalf of user will be executed atomically together with the entry point call. Therefore, we need to use `require_auth()` on the user in the invoking function.
Even though the invoking function may not require the user’s authorization, it's recommended to authorize the user at the entry point. Without that, the authorized inner `add()` call can be front-run by anyone without being wrapped in `add_with()`. Adding `require_auth()` at the entry point ensures that all the inner contract calls that are authorized on behalf of the user will be executed atomically together with the entry point call. Therefore, we need to use `require_auth()` on the user in the invoking function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think we should use user instead of just 'user' here to make it clear that we're talking about the concrete variable and not some abstract contract user.


This is how the function looks:

Expand Down