Move.

Post

Share your knowledge.

Bolke .
Jan 17, 2025
Expert Q&A

How can I implement whitelist access in sui move?

I'm trying to set up access control in Sui Move similar to how it's done in Ethereum Solidity. In Solidity, a contract ensures that only whitelisted addresses can call certain functions. You set up a whitelist and check against msg.sender during cross-contract interactions. How can I achieve similar functionality in Sui Move with package-to-package access control?

  • Move CLI
2
2
Share
Comments
.

Answers

2
yhant3.
Jan 17 2025, 23:35

In Sui Move, you can achieve similar access control by minting a 'WhiteListCap' object for the entities that should have access. Here's how it works:

  1. Define a struct for WhiteListCap that includes an UID field.
  2. Create an 'AdminCap' that is required for minting new whitelist entries.
  3. The admin can call a function to generate a WhiteListCap and transfer it to a specific address.
  4. Function calls that should be restricted can require a WhiteListCap parameter to ensure only whitelisted entities can execute them .

However, revoking access in Sui Move might be tricky since the admin loses control over the WhiteListCap once transferred.

1
Best Answer
Comments
.
LargeCappWithTwo.
Jan 18 2025, 00:36

If you’re working with smart contracts or packages that may need iterative updates, be aware that Sui Move packages are immutable. Ensure you implement upgrade-friendly code patterns, like managing object-level permissions rather than package-level, and consider using version-based access controls .

0
Comments
.

Do you know the answer?

Please log in and share it.

Move is an executable bytecode language used to implement custom transactions and smart contracts.

148Posts231Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignJune
We use cookies to ensure you get the best experience on our website.
More info