How to call a method on a component protected by an authrule?

44 Views Asked by At

On my blueprint, I defined a method buy_hotdog(&mut self, payment: Bucket) and when instantiating my component, I defined the access rules like this:

let access_rules = AccessRules::new()
  .method("buy_hotdog", rule!(require(customer.resource_address())), AccessRule::DenyAll)
  .default(AccessRule::AllowAll, AccessRule::DenyAll);

But how can a customer actually call this method?

1

There are 1 best solutions below

0
Russo On

your resource_address is also known as badge token address.

The caller of "buy_hotdog" should have that badge token(s) before calling that function.