Hi,
Iโm following flow tutorials and need help with contract level access controls.
Example: I want to extend ExampleNFT to have a flag that can be set only by the NFTโs owner but read by everyone.
- I added a pub var flag [isLostOrStolen]
- Created a setter with access(account) access [setLostOrStolen]
See the code here: https://testnet.flowscan.org/contract/A.b9af6584a32f2225.BlockchainBackedItem1
When I try to execute:
import BlockchainBackedItem1 from 0xb9af6584a32f2225
transaction(id: UInt64) {
prepare(signer: AuthAccount) {
let collectionRef = signer.getCapability(BlockchainBackedItem1.CollectionPublicPath)
.borrow<&{BlockchainBackedItem1.BlockchainBackedItemCollectionPublic}>()
?? panic("Could not get receiver reference to the NFT Collection")
let bbi = collectionRef.borrowBlockchainBackedItem(id: id)
bbi.setLostOrStolen()
}
}
I get
|
12 | bbi.setLostOrStolen()
| ^^^^^^^^^^^^^^^ unknown member
It looks like I canโt access functions with account(access) using a transaction signed by the account owner.
Am I doing something wrong?
I could create an Admin resource that has a public function that flips the flag and is stored in the account without creating a public capability, to restrict the access, but it sounds overcomplicated. What is an advised approach to implement a simple flag that is modified by the account owner?