JSPM

@skinsprotocol/sdk

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q76912F
  • License MIT

SDK for game developers to interact with the Skins Protocol

Package Exports

  • @skinsprotocol/sdk

Readme

Skins Protocol

Skins Protocol SDK

CI

A TypeScript SDK for game developers to interact with the Skins Protocol on Base network. This SDK provides a comprehensive interface for deploying game-specific NFT contracts, minting NFTs, and interacting with the marketplace.

Installation

npm install @exeedme/skins-protocol-sdk

Features

NFT Operations

  • Deploy game-specific NFT contracts (ERC721/ERC1155)
  • Mint NFTs with custom metadata
  • Transfer NFTs
  • Check balances and ownership
  • Manage approvals
  • Batch operations for deployment and minting

Token Operations (ERC20)

  • Check token balances
  • Manage token allowances
  • Transfer tokens
  • Transfer tokens on behalf of others

Marketplace Operations

  • Create and manage asks (sell orders)
  • Create and manage bids (buy orders)
  • Update order deadlines
  • Cancel orders
  • Accept orders
  • Replace orders
  • Get royalty information

Usage

import {
  SkinsProtocolSDK,
  createPublicClient,
  createWalletClient,
  http,
  privateKeyToAccount,
  baseSepolia
} from '@exeedme/skins-protocol-sdk';

const MARKETPLACE_CONTRACT_ADDRESS = '0xc500ea02e6f4D71a82d2Fba26c3e708C6CAbb40C';

const ipfsClient = new IPFSClient({
  pinataJWT: 'YOUR_JWT',
  pinataOptions: {
    pinataMetadata: {
      name: 'FILE_NAME'
    }
  }
});
 const alchemyTransport = http('YOUR_ACCOUNT');

 const sdk = new SkinsProtocolSDK({
    publicClient: createPublicClient({
      chain: baseSepolia,
      transport: alchemyTransport,
      batch: {
        multicall: true
      }
    }) as PublicClient,
    walletClient: a,
    account,
    marketplaceAddress: MARKETPLACE_ADDRESS,
    ipfs: ipfsClient
  });


// Initialize the SDK
const sdk = new SkinsProtocolSDK({
  publicClient: createPublicClient({
    chain: baseSepolia, 
    transport: http()
  }),
  walletClient: createWalletClient({
    chain: baseSepolia,
    transport: http()
  }),
  account: privateKeyToAccount('YOUR_PRIVATE_KEY'),
  marketplaceAddress: MARKETPLACE_CONTRACT_ADDRESS,
  ipfs: ipfsClient,
});

// Mint an NFT
const { hash, metadataCid } = await sdk.nft.mint(
  address,
  'RECIPIENT_ADDRESS',
  'ipfs://your-nft-metadata-cid'
);

// Create a marketplace listing (ask)
const ask = await sdk.marketplace.createAsk(
  address, // NFT contract address
  1n, // tokenId
  1n, // amount
  'CURRENCY_ADDRESS', // e.g., WETH address
  1000000000000000000n, // price per unit (1 ETH in wei)
  BigInt(Math.floor(Date.now() / 1000) + 86400) // 24h deadline
);

// Place a bid
const bid = await sdk.marketplace.createBid(
  address, // NFT contract address
  1n, // tokenId
  1n, // amount
  'CURRENCY_ADDRESS', // e.g., WETH address
  1000000000000000000n, // price per unit (1 ETH in wei)
  BigInt(Math.floor(Date.now() / 1000) + 86400) // 24h deadline
);

// Batch operations
const batchMintResult = await sdk.nft.batchMint([
  {
    contractAddress: address,
    metadata: {
      name: 'Item 1',
      description: 'First item',
      image: 'ipfs://item1-cid',
      tokenURI: 'ipfs://metadata1-cid'
    }
  },
  {
    contractAddress: address,
    metadata: {
      name: 'Item 2',
      description: 'Second item',
      image: 'ipfs://item2-cid',
      tokenURI: 'ipfs://metadata2-cid'
    }
  }
]);

Network Support

The SDK supports the following networks:

  • Base Mainnet
  • Base Sepolia (Testnet)

Configuration Options

IPFS

  • Support for Pinata and Infura IPFS services
  • Configurable API keys and endpoints

Caching

  • In-memory cache for frequently accessed data
  • Configurable cache size and TTL

Rate Limiting

  • Built-in rate limiting for API calls
  • Configurable request limits and windows

Batch Operations

  • Concurrent batch processing for deployments and mints
  • Configurable concurrency limits

Error Handling

The SDK provides detailed error types for different failure scenarios:

  • SDKError: Base error class
  • AuthenticationError: Authentication failures
  • ContractError: Smart contract interaction failures
  • IPFSError: IPFS operations failures
  • MarketplaceError: Marketplace operation failures
  • ValidationError: Input validation failures
  • NetworkError: Network-related failures
  • TransactionError: Transaction-related failures
  • ConfigurationError: SDK configuration failures
  • RateLimitError: Rate limit exceeded errors

Event Handling

// Subscribe to contract events
const unsubscribe = await sdk.subscribeToEvents(
  {
    address: contractAddress,
    eventName: 'Transfer',
    abi: NFT_ABI
  },
  (event) => {
    console.log('Transfer event:', event);
  }
);

// Unsubscribe from events
unsubscribe();

Security Considerations

  • Never commit private keys or API keys to version control
  • Use environment variables for sensitive configuration
  • Implement proper access control in your application
  • Validate all input parameters before making transactions
  • Monitor gas costs and transaction limits

License

MIT