🌟 Photo Sharing Tips: How to Stand Out and Win?
1.Highlight Gate Elements: Include Gate logo, app screens, merchandise or event collab products.
2.Keep it Clear: Use bright, focused photos with simple backgrounds. Show Gate moments in daily life, travel, sports, etc.
3.Add Creative Flair: Creative shots, vlogs, hand-drawn art, or DIY works will stand out! Try a special [You and Gate] pose.
4.Share Your Story: Sincere captions about your memories, growth, or wishes with Gate add an extra touch and impress the judges.
5.Share on Multiple Platforms: Posting on Twitter (X) boosts your exposure an
Rust Smart Contracts Security Advanced: Permission Control and Access Management Practices
Rust Smart Contracts Development Diary (7) Contract Security and Permission Control
This article will introduce permission control in Rust smart contracts from two perspectives:
1. Contract Function Visibility
Visibility control of contract functions is crucial for protecting key functionalities. For example, in the security incident of Bancor Network exchange in June 2020, the risk to user assets arose because a critical transfer function was mistakenly set to public.
In Rust smart contracts, there are the following types of function visibility:
Additionally, defining a function in an impl block that is not modified by #[near_bindgen] can also make it an internal function.
For the callback function, it must be set to public but also ensure that it can only be called by the contract itself. This functionality can be achieved using the #[private] macro.
It should be noted that the default visibility in Rust is private, which is different from the default public in some versions of Solidity. The exceptions are that items in pub trait and pub enum are public by default.
2. Access Control of Privileged Functions
In addition to function visibility, a whitelist mechanism needs to be established to control access to privileged functions. Similar to the onlyOwner modifier in Solidity, an Ownable trait can be implemented:
rust pub trait Ownable { fn assert_owner(&self) { assert_eq!(env::predecessor_account_id(), self.get_owner()); } AccountId; fn set_owner(&mut self, owner: AccountId); }
This trait can restrict only the owner from calling certain privileged functions. Based on this principle, more complex whitelists can be set up to achieve fine-grained access control.
3. Other Access Control Methods
Other access control methods such as contract invocation timing control, multi-signature invocation mechanism, and DAO governance can also be considered. These will be detailed in subsequent articles.