Tokenholder Specifications
How to Apply Transfer Restrictions for Compliant Security Tokens
👀 Overview
This tutorial application will teach you how to add transfer restrictions to token holders in 3 simple steps:
Fetch security tokens that belong to the current user.
Fetch Tokenholders.
Add, update and remove Tokenholders.
👇 Fetching Tokens
Once we've established an SDK connection, we can fetch the security tokens owned by the current address in Metamask.
The SDK will query the SecurityTokenRegistry for tokens owned by walletAddress.
🤝 Fetching Tokenholders
Use the SDK to fetch an array of tokenholders. Start by running your async code in a useEffect() hook. Note that the effect won't run unless the user has selected a token, or if you're reloading the tokenholders list deliberately (via relaodTokenholders).
Note that contrary to fetching tokens, fetching tokenholders is a method of the SecurityToken entity objet rather than a top-level method:
vs
Tokenholder-related methods are grouped under the .tokenholders namespace.
The app state contains the tokens array fetched earlier. You can access the currently selected tokens by tokens[selectedToken].
🗃️ Adding, Editing, and Deleting Tokenholders
First, add event handlers to the App component. You can add these functions anywhere in the App function:
modifyWhitelist: A submit handler for the tokenholder form. The handler receives an array of tokenholder data objects (which include the tokenholder Ethereum addresses, buy and sell lockup dates and their KYC expiry dates). Eventually, the function uses the SDK'smodifyDataas follows:
removeTokenholders: A handler for thedeletebutton. It will call the SDK'srevokeKycto revoke KYC for passed addresses.
Now, add the add/edit tokenholder form. First, create a wrapper component Whitelist, which will wrap the form as well as the tokenholders table we've created in previous steps.
Feel free to substitute the Ant Design library used here with any other library you're familiar with.
Last updated
Was this helpful?