🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

dotcv-solana

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotcv-solana

Smart Contract Library

0.0.3
latest
Source
npm
Version published
Weekly downloads
18
-60.87%
Maintainers
1
Weekly downloads
 
Created
Source

DotCv SDK

A TypeScript client library for DotCv's Solana program that enables domain registration, record management, and payment routing.

Installation

npm install dotcv-solana --save

OR

yarn add dotcv-solana

Usage

Initializing the SDK

import { DotCvWeb3 } from 'dotcv-solana';

const web3 = new DotCvWeb3(
  process.env.DOTCV_SIGNER_KEY, // Private key for admin operations
  'devnet', // Network: "devnet" or "mainnet-beta"
  {
    mainnet: 'https://api.mainnet-beta.solana.com',
    devnet: 'https://api.devnet.solana.com',
  },
  'dotcv.sol' // Your parent domain
);

Domain Management

// Create a domain registrar
const registrar = await web3.createRegistrar();

// Register a subdomain (admin)
const txHash = await web3.adminRegisterSubDomain('subdomain');

// Register a subdomain (user)
const serializedTx = await web3.registerSubDomain(
  'subdomain',
  'buyerPublicKey'
);

// Transfer subdomain ownership
const transferTx = await web3.transferSubDomain(
  'subdomain',
  'newOwnerPublicKey'
);

// Resolve domain information
const domainInfo = await web3.resolveDomain('subdomain');

Record Management

// Create a record
const recordTx = await web3.createRecord(
  'subdomain',
  '@twitterhandle',
  'domainOwnerPublicKey',
  Record.Twitter
);

// Edit a record
const editTx = await web3.editRecord(
  'subdomain',
  '@newhandle',
  'domainOwnerPublicKey',
  Record.Twitter
);

Payment Router

// Initialize payment router
const routerInit = await web3.initializePaymentRouter('subdomain', [
  { wallet: 'wallet1PublicKey', percentage: 60 },
  { wallet: 'wallet2PublicKey', percentage: 40 },
]);

// Distribute funds
const distribution = await web3.distribute(
  'subdomain',
  1000000000, // Amount in lamports
  true, // isSol
  'mintAddress' // Optional: for SPL tokens
);

// Setup webhook for payment monitoring
const webhook = await setupPaymentRouterWebhook(
  'heliusApiKey',
  routerInit.paymentRouterPDA,
  'devnet',
  'https://your-webhook.url'
);

Interface Types

Distribution Rules

interface DistributionRuleInput {
  wallet: string; // Wallet address as base58 string
  percentage: number; // Percentage of distribution (0-100)
}

API Endpoints

interface ApiEndpoints {
  mainnet: string; // Mainnet RPC URL
  devnet: string; // Devnet RPC URL
}

Webhook Configuration

interface WebhookConfig {
  webhookUrl: string;
  accountAddresses: string[];
  transactionTypes: string[];
  webhookType: string;
}

Error Handling

The SDK includes comprehensive error handling. Most methods will throw detailed errors that should be caught and handled appropriately:

try {
  const distribution = await web3.distribute(...);
} catch (error) {
  if (error.message.includes('unauthorized')) {
    // Handle authentication errors
  }
  // Handle other errors
}

Network Support

The SDK supports both Solana mainnet and devnet environments. Specify the network when initializing the SDK:

  • Devnet: "devnet"
  • Mainnet: "mainnet-beta"

Security Considerations

  • Keep your private keys secure and never expose them in client-side code
  • Use environment variables for sensitive configuration
  • Validate all input parameters before passing them to SDK methods
  • Monitor webhook endpoints for unauthorized access

License

[Add your license information here]

FAQs

Package last updated on 24 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts