API token and Secret needs to be requested from TransferChain via support@transferchain.io or please contact your customer success manager to obtain them.
Initialize TransferChain
```python# Import the TransferChain class from the SDKfrom transferchain.client import TransferChain# Initialize TransferChaintc =TransferChain()```
Add Master User
```python# Import the TransferChain class from the SDKfrom transferchain.client import TransferChain# Initialize TransferChaintc =TransferChain()# When the SDK is initialized for the first time, creating a master user for that SDK is facilitated by using the 'add_master_user' operation.
# Example: Create a Master Userresult_add_master_user = tc.add_master_user()master_user = result_add_master_user.dataprint(f"Master User created: {master_user.id}")```
Add User
```python# Import the TransferChain class from the SDKfrom transferchain.client import TransferChain# Initialize TransferChaintc =TransferChain()# Example: Add a Userresult_add_user = tc.add_user()added_user = result_add_user.dataprint(f"User added: {added_user.id}")```
Get User
```python# Import the TransferChain class from the SDKimport osfrom transferchain.client import TransferChain# Initialize TransferChaintc =TransferChain()# Get TRANSFERCHAIN_USER_ID variable from envuser_id = os.environ.get('TRANSFERCHAIN_USER_ID')# When any storage or transfer operation is desired, a user is required, and the 'get_user' method provides the necessary information related to the required user.
# Example: Get a Useruser_id_to_get = user_iduser_info = tc.get_user(user_id_to_get)print(f"User information: {user_info.id}")```
Restore Master User
```python# Import the TransferChain class from the SDKfrom transferchain.client import TransferChain# Initialize TransferChaintc =TransferChain()# It writes the addresses of the master and user in the blockchain to the SDK database using the mnemonics found in the environment, and returns all transactions found to the SDK user.
# Example: Restore a Master Userresult_restore_master_user = tc.restore_master_user()restored_master_user = result_restore_master_user.dataprint(f"Master User restored: {restored_master_user}")```