Skip to content

Update solana #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nodes/misc/solana/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ADMIN_KEY =

USER_KEY =

CLUSTER =LOCALNET

CUSTOM_RPC =https://solana-devnet.g.alchemy.com/v2/
Empty file.
138 changes: 109 additions & 29 deletions nodes/misc/solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ A command-line tool for managing nodes on the Solana blockchain using the NetSep
2. Install dependencies:
```bash
npm install
or
yarn
```

## Available Commands

### User Commands (netsepioV1_user.js)
### User Commands (netsepio_user.js)

#### Register a Node

Register a new node with the NetSepio program.

```bash
node netsepioV1_user.js registerNode <nodeId> <name> <nodeType> <config> <ipaddress> <region> <location> <metadata> <owner>
node netsepio_user.js registerNode <nodeId> <name> <nodeType> <config> <ipaddress> <region> <location> <metadata> <owner>
```

Parameters:
Expand All @@ -47,74 +49,134 @@ Parameters:
Example:

```bash
node netsepioV1_user.js registerNode \
node-123 \
"Luffy" \
node netsepio_user.js registerNode \
"node-$(($RANDOM % 10000))" \
"Zoro" \
validator \
'{"cpu":"16 cores","memory":"64GB","disk":"5TB"}' \
34.92.123.456 \
us-east \
"New York, NY" \
'{"version":"2.0.1","lastUpdate":"2023-06-15"}' \
"3nKn5GhMTJ1hHCYjhWAV1etPfypWBqM9dpPrW85VfPWD"
"EdPJtnunTwxQLo3FCNWN464VLJMb4B6LhBN2HrbAYKpD"
```

#### Get Node Data
#### Create Checkpoint

Retrieve information about a registered node.
Create a checkpoint for a node.

```bash
node netsepioV1_user.js get <nodeId>
node netsepio_user.js createCheckpoint <nodeId> <checkpointData>
```

#### Create Checkpoint

Create a checkpoint for a node.
Example:

```bash
node netsepioV1_user.js createCheckpoint <nodeId> <checkpointData>
node netsepio_user.js createCheckpoint node-1234 '{"timestamp":"2023-05-15T12:00:00Z","status":"healthy","metrics":{"uptime":"99.9%","cpu":"45%","memory":"60%"}}'
```

#### Deactivate Node

Deactivate a registered node.

```bash
node netsepioV1_user.js deactivateNode <nodeId>
node netsepio_user.js deactivateNode <nodeId>
```

Example:

```bash
node netsepio_user.js deactivateNode node-1234 CollectionPublicKeyHere
```

#### Force Deactivate Node

```bash
node netsepio_user.js forceDeactivate <nodeId>

```

### Admin Commands (netsepioV1_admin.js)
Example:

```bash
node netsepio_user.js forceDeactivate node-1234
```

#### Get Node Data

Retrieve information about a registered node.

```bash
node netsepio_user.js getNodeData <nodeId>
```

Example :

```bash
node netsepio_user.js getNodeData node-1234
```

#### CHECK BALANCE

Check your SOL balance for the keypair address.

```bash
node netsepio_user.js checkBalance
```


### Admin Commands (netsepio_admin.js)

#### INTIALIZE GLOBAL CONFIG

ADMIN WILL INTIALIZE THE GLOBAL CONFIG

```bash
node netsepio_admin.js intializeGlobalConfig
```

#### Create Collection

Create a new NFT collection.

```bash
node netsepioV1_admin.js createCollection <collectionName> <collectionUri>
node netsepio_admin.js createCollection <collectionName> <collectionUri>
```

Example:

```bash
node netsepio_admin.js createCollection NetSepio www.exampleuri.com
```

#### Mint NFT

Mint a new NFT for a node.

```bash
node netsepioV1_admin.js mintNFT <nodeId> <nftName> <nftUri> <owner>
node netsepio_admin.js mintNFT <nodeId> <nftName> <nftUri> <owner>
```

Example:

```bash
node netsepio_admin.js mintNFT node-6909 CyberPunk1 "www.exampleuri.com" EdPJtnunTwxQLo3FCNWN464VLJMb4B6LhBN2HrbAYKpD
```

#### Update Metadata

Update NFT metadata.

```bash
node netsepioV1_admin.js updateMetadata <assetKeypair> <collectionKey> <newNftUri>
node netsepio_admin.js updateMetadata <newNftUri>
```

#### Update Node Status

Update the status of a node.

```bash
node netsepioV1_admin.js updateNodeStatus <nodeId> <newStatus>
node netsepio_admin.js updateNodeStatus <nodeId> <newStatus>
```

## Node Status Values
Expand All @@ -127,11 +189,35 @@ The node status can be one of the following:

## Keypair Management

The scripts automatically handle keypair management:
The scripts use keypair configuration from the .env file:

- If `Keypair.json` exists, it will be used
- If not, a new keypair will be generated and saved
- The keypair is used for signing transactions
- Add your Keypair to .env as follows:
- For user operations: `USER_KEY=[your_private_key_array]`
- For admin operations: `ADMIN_KEY=[your_private_key_array]`
- For collection operations: `COLLECTION_KEYPAIR=[your_collection_keypair_array]`
- If no private key is provided, the script will exit with an error

## Network Configuration

The network connection is configured through the .env file:

- Set `CLUSTER` to one of the following values:
- `LOCALNET`: Connect to local Solana node (http://127.0.0.1:8899)
- `DEVNET`: Connect to Solana devnet (https://api.devnet.solana.com)
- `TESTNET`: Connect to Solana testnet (https://api.testnet.solana.com)
- `CUSTOM`: Connect to custom RPC endpoint specified in `CUSTOM_RPC`
- For custom RPC connections, set `CUSTOM_RPC` to your RPC provider's URL (e.g., from Alchemy)

Example .env file:

```bash
CLUSTER=DEVNET
```
and

```bash
CUSTOM_RPC=https://your-custom-rpc-endpoint.com
```

## Error Handling

Expand All @@ -143,12 +229,6 @@ All commands return JSON-formatted responses with:
- `data`: Additional data (if successful)
- `error`: Error message (if failed)

## Network Configuration

- All operations are performed on the Solana devnet
- Connection URL: `https://api.devnet.solana.com`
- Commitment level: `confirmed`

## Notes

- Ensure your wallet has sufficient SOL for transactions
Expand Down
Empty file removed nodes/misc/solana/UserKeypair.json
Empty file.
Loading