droplinked-web3-kit
v1.0.13
Published
The official Web3 SDK for Droplinked, providing a unified interface for interacting with multiple blockchains (EVM, Solana, etc.), wallets, and Droplinked platform services. This library simplifies wallet connection, authentication, payments, NFT claiming
Readme
Droplinked Web3 Kit
The official Web3 SDK for Droplinked, providing a unified interface for interacting with multiple blockchains (EVM, Solana, etc.), wallets, and Droplinked platform services. This library simplifies wallet connection, authentication, payments, NFT claiming, and product recording on-chain.
Installation
npm install droplinked-web3-kitFeatures
- Multi-Chain Support: Ethereum, Polygon, Binance Smart Chain, Base, Linea, Skale, Solana, Redbelly, Xion, and more.
- Multi-Wallet Support: Metamask, Phantom, Trust Wallet, Unstoppable Domains, Xion.
- Unified API: Consistent interface for all actions across different chains and wallets.
- Built-in Actions: Login, Authentication, Payments, NFT Claims, Product Recording.
Getting Started
Initialization
Import DropWeb3 and Network to initialize the SDK. You must call getProvider() to initialize the wallet providers.
import { DropWeb3, Network } from 'droplinked-web3-kit';
// Initialize the SDK (Network.TESTNET or Network.MAINNET)
const dropWeb3 = new DropWeb3(Network.TESTNET);
// Initialize wallet providers and ready the SDK
await dropWeb3.getProvider();Wallet Management
List Supported Wallets
Get a list of all wallets supported by the SDK.
const supportedWallets = dropWeb3.getSupportedWallets();
console.log(supportedWallets);
// Output: [{ walletName: 'Metamask', group: 'EVM' }, { walletName: 'Phantom', group: 'SOL' }, ...]Check Wallet Status
Retrieve detailed information about all wallets, including installation status, connection status, and download links.
const allWalletsInfo = await dropWeb3.getAllWallets();
allWalletsInfo.forEach(wallet => {
console.log(`${wallet.walletName}: Installed=${wallet.isInstalled}, Connected=${wallet.isConnected}`);
if (!wallet.isInstalled) {
console.log(`Download here: ${wallet.installationLink.website}`);
}
});Get Connected Wallets
Get instances of currently connected wallet adapters.
const connectedWallets = await dropWeb3.getConnectedWallets();Actions
All actions are performed using the DropWeb3 instance. Most actions require specifying the wallet (enum) and an input object.
Enums
import { Wallets, Chains, PaymentTokens } from 'droplinked-web3-kit';1. Login (Connect Wallet)
Connects the specified wallet and retrieves the user's address.
const response = await dropWeb3.login(Wallets.Metamask, {
chain: Chains.ETH // or Chains.POLYGON, Chains.SOLANA, etc.
});
console.log('User Address:', response.address);Unstoppable Domains Login:
const response = await dropWeb3.login(Wallets.UnstoppableDomains, {
chain: Chains.UNSTOPPABLE,
udClientId: 'YOUR_CLIENT_ID',
redirectUri: 'YOUR_REDIRECT_URI'
});2. Authentication (Sign Message)
Requests the user to sign a message to prove ownership of the wallet. This is used for secure authentication with the Droplinked backend.
const authResponse = await dropWeb3.auth(Wallets.Metamask, {
chain: Chains.ETH
});
console.log('Signature:', authResponse.signature);
console.log('Message/Nonce:', authResponse.nonce);3. Payment
Process a crypto payment for an order.
const paymentResponse = await dropWeb3.payment(Wallets.Metamask, {
chain: Chains.ETH,
shopId: 'SHOP_ID_FROM_BACKEND',
orderID: 'ORDER_ID_FROM_BACKEND',
paymentToken: PaymentTokens.ETH // or PaymentTokens.USDC, etc.
});
console.log('Transaction Hash:', paymentResponse.transactionHash);4. Claim NFT
Claim an NFT associated with a product (e.g., for digital twins or token-gated access).
const claimResponse = await dropWeb3.claimNFT(Wallets.Metamask, {
orderId: 'ORDER_ID',
skuId: 'SKU_ID'
});
console.log('Claim Transaction:', claimResponse.transactionHash);5. Record Product
Record a product's details on-chain.
const recordResponse = await dropWeb3.recordProduct(Wallets.Metamask, {
chain: Chains.POLYGON,
productId: 'PRODUCT_ID',
shopId: 'SHOP_ID'
});
console.log('Record Transaction:', recordResponse.transactionHash);Customization
Custom Stepizer (UI Feedback)
You can provide a custom Stepizer to handle UI updates (loading states, success messages, errors) during async operations.
import { Stepizer, DropWeb3, Network } from 'droplinked-web3-kit';
class MyUIStepizer extends Stepizer {
async changeStep(description: string) {
console.log('UI Loading:', description);
// Update your UI loading state here
}
async error(error: string, description: string) {
console.error('UI Error:', error);
// Show error notification
}
async success(description: string) {
console.log('UI Success:', description);
// Show success notification
}
}
const dropWeb3 = new DropWeb3(Network.TESTNET, new MyUIStepizer("MyStepizer"));Supported Chains & Wallets
Chains
- EVM: Ethereum, Polygon, Binance Smart Chain, Base, Linea, Skale, Redbelly, Bitlayer.
- Solana: Solana Mainnet/Devnet.
- Cosmos/Other: Xion.
Wallets
- Metamask (EVM)
- Phantom (Solana, Bitcoin, EVM)
- Trust Wallet (EVM)
- Unstoppable Domains
- Xion (Email/Web2 Login)
