SDK / CLI Documentation
This guide provides instructions on how to interact with Gridlock's network. It is intended for developers looking to build on Gridlock's storage technology.
Initialize SDK
Start by initializing the Gridlock SDK to use the built-in functions.
Parameters:
apiKey
(string): Your API key for authentication into the chosen network.baseUrl
(string): The URL endpoint for the backend orchestration "orch" node(s).verbose
(boolean): Set to true to see additional debug informationlogger
(object): A logging instance for outputting logs (e.g., console, winston).
Create User (createUser
)
createUser
)Description: Creates a new empty user account.
Parameters:
name
(string): The user's full nameemail
(string): The user's email address, used for authentication.password
(string): The user's password used to encrypt access key stored locally.saveCredentials
(boolean): Option to save the user's credentials locally for easier management. UsesaveStoredCredntials
andclearStoredCredentials
functions to switch to another saved user.
Return Values:
user
(object): JSON object containing user account details.authTokens
(object): JSON object containing temporary authentication tokens for session management.
Example Usage:
Additional Guidance:
The user's node pool will initiate in an empty state. The next step is to add guardians to the user's storage network.
Add Guardian (addGuardian
)
addGuardian
)Description: Adds a self-hosted guardian to the user's node pool.
Parameters:
email
(string): The user's email address, used for authentication.password
(string): The user's password for local decryption of access key.guardian
(object): Object containing information about the guardian. Details below.name
(string): The guardian’s name.type
(string): The type of guardian, currently limited tocloud
nodeId
(string): Unique identifier for the guardian.publicKey
(string): The guardian’s public key used for identification.e2ePublicKey
(string): The guardian’s public key used for end-to-end encryption.
isOwnerGuardian
(boolean): Indicates if the user is the owner guardian.
Return Values:
user
(object): JSON object containing user detailsguardian
(object): JSON object containing guardian details.
Example Usage:
Add Professional Guardian (addProfessionalGuardian
)
addProfessionalGuardian
)Description: Adds a Gridlock-hosted guardian to the user's node pool.
Parameters:
email
(string): The user's email address, used for authentication.password
(string): The user's password for local decryption of access key.type
(string): The type of professional guardian, eithergridlock
orpartner
Return Values:
user
(object): JSON object containing user detailsguardian
(object): JSON object containing guardian details.
Example Usage:
Additional Guidance:
Professional Guardians cannot be assigned as “Owner Guardian” because they are not meant to serve as the primary controllers of assets.
Create Wallet (createWallet
)
createWallet
)Description: Generates a distributed private key and address for the given user and blockchain.
Parameters:
email
(string): The user's email address, used for authentication.password
(string): The user's password for local decryption of access key.blockchain
(string): Blockchain identifier (e.g., 'DOT', 'BTC', 'ETH').
Return Value:
wallet
(object): JSON object with address information and associated guardians
Example Usage:
Additional Guidance:
You must have sufficient guardians assigned before creating a wallet.
The private key is generated using Distributed Key Generation (DKG) through communication with all guardians in the node pool. The key will never exist as a whole.
Sign Transaction (signTransaction
)
signTransaction
)Description: Signs a given transaction for the user.
Parameters:
email
(string): The user's email address, used for authentication.password
(string): The user's password for local decryption of access key.address
(string): The related blockchain address.message
(string): The transaction message to be signed.
Return Value:
signature
(object): JSON object containing a signature and other associated data.
Example Usage:
Additional Guidance:
The system gathers partial signatures from the user’s guardians within the node pool. Once enough guardians have signed, the system automatically aggregates them to finalize the transaction. It's possible for this process to fail in guardians are offline. This itself is a form of security where you can choose to have guardians regularly offline so that transactions are not possible.
Verify Signature (verifySignature
)
verifySignature
)Description: Confirms that all nodes in the user's node pool can produce a valid signature for a specified address.
Parameters:
email
(string): The user's email address, used for authentication.password
(string): The user's password for local decryption of access key.message
(string): The transaction message that you want to verify.address
(string): The address that signed the messagesignature
(string): The signature you want to verify.
Return Value:
verified
(object): A JSON object containing verified as true or false.
Example Usage:
Start Recovery (startRecovery
)
startRecovery
)Description: Initiates the account recovery process with a user's email.
Parameters:
email
(string): The user's email addresspassword
(string): New (or previous) password used to encrypt locally stored credentials.
Return Value:
guardians
(object): A JSON object containing the list of guardians associated with that user.
Example Usage:
Additional Guidance:
If the user is found, an email will also be sent to the address they registered with their guardians when they first created the account.
Recovery in this distributed system functions similarly to the “forgot password” process in a traditional system. If the user exists, this call returns a list of their associated guardians. This list is used for future end-to-end encrypted communication during the recovery process.
Confirm Recovery (confirmRecovery
)
confirmRecovery
)Description: Confirms ownership of email address by sharing the recovery code with the guardian.
Parameters:
email
(string): The user's email addresspassword
(string): The user's password for local decryption of access key.recoveryBundle
(string): Information sent by the guardian to the user's email.
Return Value:
user
(object): A JSON object containing the user's information.wallets
(object): A JSON object containing all wallets associated with that user.
Example Usage:
Additional Guidance:
The recovery bundle contains information about the specific guardian that sent the code as well as a unique challenge that lets the user prove they have access to the correct email.
Transfer Owner (transferOwner
)
transferOwner
)Description: Transfers primary ownership of the account to a new client device, assuming sufficient guardians have been updated via the Confirm Recovery action.
Parameters:
email
(string): The user's email address, used for authentication.password
(string): The user's password for local decryption of access key.
Return Value:
success
(bool): Booleen value showing success or failure of transfer request.
Example Usage:
Additional Guidance:
This function only succeeds if enough guardians have already confirmed the new device. The orch node checks the current status of each guardian. If the required number have approved, it updates the account to make the new client device the one that can log into the network.
CLI-specific commands
Show Network (showNetwork
)
showNetwork
)Description: Shows guardians associated with a specific user.
Parameters:
email
(required, string): The email is used as the unique identifier of the user.
Return Value:
name
(string): The name of the node.nodeType
(string): The type of node, which can be one of the following:nodeId
(string): The unique identifier for the node.status
(string): The current status of the node (e.g., active, inactive).identityKey
(string): The public key associated with the node identity.encryptionKey
(string): The public key used by the node for end-to-end encryption.ownerGuardian
(boolean): Whether the node is designated as the Owner Guardian.
Example Usage:
Additional Guidance:
Cloud Nodes: These are nodes that you run yourself and are generally run on cloud infrastructure like AWS.
Gridlock Nodes: These nodes are run by Gridlock and perform additional functions like advanced network monitoring for extra protection.
Partner Nodes: These nodes belong to partner organizations that help enhance the network's security and distribution without having control over the user’s assets.
Last updated
Was this helpful?