solinkify-sdk
v1.0.1
Published
Official SDK for Solinkify M2M & Merchant Gateway
Downloads
273
Maintainers
Readme
Solinkify SDK & Protocol ⚡
Solinkify is a decentralized payment infrastructure on the Solana network designed to bridge digital assets with Merchants (E-commerce) and Autonomous AI Agents (M2M).
This project combines Anchor Smart Contracts, a Rust (Axum) backend for off-chain scalability, and a plug-and-play JavaScript SDK.
🚀 Key Features
- DePIN Payment Gateway: Enables third-party merchants to accept SOL with an automated fee-splitting system.
- x402 Protocol (M2M): A new standard for AI agents to autonomously purchase digital assets.
- Solana Blinks Ready: Supports direct transaction integration via social media (Twitter/X).
- Idempotency & Security: Protection against Replay Attacks using on-chain and off-chain signature verification.
📦 SDK Installation
Use NPM or Yarn to integrate Solinkify into your project:
npm install solinkify-sdk🛠 Integration Guide for Merchants (E-commerce)
Merchants can accept Solana payments without worrying about the complexities of building Web3 transactions.
Option A: Vanilla JavaScript / Node.js
Suitable for basic HTML or simple backend systems.
import { SolinkifyMerchant } from 'solinkify-sdk';
const merchant = new SolinkifyMerchant();
async function handlePayment() {
// 1. Get a ready-to-use transaction from Solinkify
const tx = await merchant.createPaymentTransaction(
"YOUR_STORE_WALLET",
"BUYER_WALLET",
0.1, // Amount in SOL
"ORDER-12345" // Order ID
);
// 2. Request buyer's wallet approval (Phantom, etc.)
const provider = window.phantom?.solana;
const { signature } = await provider.signAndSendTransaction(tx);
console.log("Payment Successful! TxID:", signature);
}Option B: React / Next.js (with Solana Wallet Adapter)
Direct integration into the checkout button in your modern frontend.
import { useWallet } from '@solana/wallet-adapter-react';
import { Connection } from '@solana/web3.js';
import { SolinkifyMerchant } from 'solinkify-sdk';
export default function CheckoutButton() {
const { publicKey, sendTransaction } = useWallet();
// Set to Devnet for the testing/development phase
const connection = new Connection("[https://api.devnet.solana.com](https://api.devnet.solana.com)");
const handleCheckout = async () => {
if (!publicKey) return alert("Please connect your wallet first!");
try {
const merchantApi = new SolinkifyMerchant();
// 1. Generate transaction from the Solinkify SDK
const tx = await merchantApi.createPaymentTransaction(
"YOUR_STORE_WALLET",
publicKey.toBase58(),
0.1,
"INV-REACT-001"
);
// 2. Execute transaction via the DApp's built-in Wallet Adapter
const signature = await sendTransaction(tx, connection);
alert(`Payment Successful! TxID: ${signature}`);
} catch (error) {
console.error("Payment failed:", error);
}
};
return (
<button
onClick={handleCheckout}
style={{ background: '#9945FF', color: 'white', padding: '10px 20px', borderRadius: '8px', cursor: 'pointer' }}
>
Pay 0.1 SOL (Devnet) via Phantom
</button>
);
}🤖 Integration Guide for AI Agents (M2M Autonomy)
Solinkify's x402 Protocol enables AI to purchase data or APIs autonomously without human intervention. The SDK handles HTTP 402 Payment Required negotiation, blockchain payments, and cryptographic verification behind the scenes.
import { SolinkifyAgent } from 'solinkify-sdk';
// Initialize with AI Private Key (Base58)
const agent = new SolinkifyAgent("YOUR_AI_PRIVATE_KEY_BASE58");
async function buyDigitalAsset() {
try {
// Automated: Get Invoice -> Pay On-Chain -> Cryptographic Sign -> Download URL
const downloadUrl = await agent.purchaseAndDownload("DIGITAL_ASSET_ID");
console.log("✅ Asset successfully purchased. Download link:", downloadUrl);
} catch (error) {
console.error("❌ Failed to purchase asset:", error.message);
}
}⛓ Protocol Information (On-Chain)
- Program ID:
AaKvuhidmnrpXdHi762sJ1xZ5TrjragS9Y6ikwFVp1tr - Network: Solana Devnet (Testing Phase)
- Gateway Tokenomics (DePIN):
- Base Fee: 1% (Minimum: 0.00015 SOL, Maximum Cap: 0.05 SOL).
- Revenue Split: 75% forwarded to Node Operators, 25% forwarded to Solinkify Admin.
🌐 API Reference (Off-Chain)
Base URL: https://api.solinkify.com/
| Endpoint | Method | Description |
| :--- | :--- | :--- |
| /gateway/create-payment | POST | Creates an unsigned M2M transaction with fee-splitting instructions for the Merchant. |
| /x402/book/:id | GET | Requests an invoice or downloads the asset (Requires 3 Security Headers). |
| /actions/buy/:id | GET/POST | Native endpoint for the Solana Blinks standard. |
| /books | GET | Fetches the list of digital assets that are live in the database. |
🛡 Security (Security Headers)
If you are not using the SolinkifyAgent module and are making API calls manually, you must include these 3 headers in the second GET request (after the on-chain payment is complete) to claim the file:
x-payment-signature: The TxID (Signature) of your SOL transfer proof on the Solana network.x-buyer-pubkey: The Public Key of the wallet used for the payment.x-auth-signature: A cryptographic signature (Ed25519) of a message containing the string${book_id}:${signature}using the buyer's private key.
📄 License
Distributed under the ISC License.
Solinkify - Empowering the Machine-to-Machine Economy on Solana. Website | API Dashboard
