Skip to content

Commit 0c1ebdc

Browse files
committed
fix: clarify root auth rationale for cross-contract calls
1 parent 89eee36 commit 0c1ebdc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/build/guides/auth/contract-authorization.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ To illustrate how to add authorization to a simple cross-contract invocation, we
252252

253253
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.
254254

255-
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.
255+
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.
256256

257257
This is how the function looks:
258258

0 commit comments

Comments
 (0)