Stake Solana Tutorial

Requirements :

  • Ledger Enteprise with the Solana Release
  • LAM setup
  • Admin access to the Ledger Enteprise Application

How to start :

  1. Create your API users
  2. Create a SOLANA Account as Reserve Cold Storage
  3. Create a SOLOANA Account to Perform Staking operations
  4. Add API user to the SOLANA Account
Copy
Copied
import requests
import json

CONSTANTES

Copy
Copied
LAM_URL = "https://split-merge-sol.minivault.ledger-sbx.com/lam"
API_USER_NAME = "bluestar"
HEADER = {'X-Ledger-API-User': API_USER_NAME}

Test LE-API connection

To see if your can reach your LAM URL.

You should get an API call code : 400, and the LAM should not know your user for now.

Copy
Copied
r = requests.get(LAM_URL + "/_health", headers=HEADER)
r.json()

MANDATORY - Create your LAM Operator

You will need to login as an Admin using the Ledger PSD to perfom this action since we will add a new operator on your HSM workspace.

This user can then be managed as any operator and can be added in your governance rules.

Login as Admin and go to the user section

Add_User_screen.png

Click Invite User

image.png

Select API and insert username and userId

Screenshot 2022-09-29 at 14.33.30.png

Inside this section set the username as API_USER_NAME for the constant section

Generate a User ID via API on your LAM via the /api_users endpoint

Copy
Copied
payload = {
  "name": API_USER_NAME
}

r = requests.post(LAM_URL + "/api_users", json=payload, headers=HEADER)
r.json()

You should get this type of response :

Copy
Copied
{
 'device_id': '6832c1a93806fca9',
 'name': 'redstar',
 'role': 'OPERATOR',
 'type_': 'SOFT_PSD',
 'workspace': 'your_workspace_name'
}

Use this your generated device Id to create the operator in the web application

For example 6832c1a93806fca9 need to be added under the User Id Section

image.png

Then register your operator via API

Copy past the UUID generated in by the web application 8436297b-962d-4e43-8a58-07b9ce84c1bc

Once done you should see {'success': True}

Copy
Copied
uuid = "97f90489-2b65-437c-9bf6-09ecd27e1723"
payload = {
  "name": API_USER_NAME
}

r = requests.post(LAM_URL + "/api_users/" + API_USER_NAME + "/register/" + uuid , json=payload, headers=HEADER)
r.json()

Login as administrators to approve the API operator