Assign Function AccessRules
- 07 Nov 2023
- 1 Minute to read
- DarkLight
- PDF
Assign Function AccessRules
- Updated on 07 Nov 2023
- 1 Minute to read
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
To specify the access rules for each function use the enable_function_auth!
macro at the top of your blueprint code.
NOTE
If the
enable_function_auth!
macro is not used that all functions will default torule!(allow_all)
AccessRule.
#[blueprint]
mod my_token_sale {
enable_function_auth! { // #1
create_component => rule!(allow_all); // #2
create_special_component => rule!(require(XRD)); // #3
}
struct MyTokenSale { .. }
impl MyTokenSale {
pub fn create_component() -> Global<MyTokenSale> { .. }
pub fn create_special_component() -> Global<MyTokenSale> { .. }
..
}
}
Each
pub
function inimpl MyTokenSale { .. }
must be assigned an AccessRule if theenable_function_auth!
macro is used. Non-pub
functions are never accessible.rule!(allow_all)
specifies that anyone may call thecreate_component
functionrule!(require(XRD))
specifies that only a caller who has a proof of XRD in their AuthZone may call thecreate_special_component
function
Was this article helpful?