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 SDK
from transferchain.client import TransferChain
# Initialize TransferChain
tc = TransferChain()
```
Add Master User
```python
# Import the TransferChain class from the SDK
from transferchain.client import TransferChain
# Initialize TransferChain
tc = 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 User
result_add_master_user = tc.add_master_user()
master_user = result_add_master_user.data
print(f"Master User created: {master_user.id}")
```
Add User
```python
# Import the TransferChain class from the SDK
from transferchain.client import TransferChain
# Initialize TransferChain
tc = TransferChain()
# Example: Add a User
result_add_user = tc.add_user()
added_user = result_add_user.data
print(f"User added: {added_user.id}")
```
Get User
```python
# Import the TransferChain class from the SDK
import os
from transferchain.client import TransferChain
# Initialize TransferChain
tc = TransferChain()
# Get TRANSFERCHAIN_USER_ID variable from env
user_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 User
user_id_to_get = user_id
user_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 SDK
from transferchain.client import TransferChain
# Initialize TransferChain
tc = 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 User
result_restore_master_user = tc.restore_master_user()
restored_master_user = result_restore_master_user.data
print(f"Master User restored: {restored_master_user}")
```