npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xeggo/drop-sdk

v1.0.2

Published

It's either possible to generate links and campaigns using our [Dashboard](https://dashboard.xeggo.io) or using SDK:

Downloads

5

Readme

xeggo SDK

It's either possible to generate links and campaigns using our Dashboard or using SDK:

Short description

SDK for computing proxy address, generating and claiming xeggos

Installation

yarn add @xeggo/drop-sdk

Usage

const xeggoSDK = require("@xeggo/drop-sdk");

// OR

import xeggoSDK from "@xeggo/drop-sdk";

Initialization

const xeggoSDK = new xeggoSDK({
  xeggoMasterAddress,
  factoryAddress,
  сhain = 'mainnet',
  jsonRpcUrl = `https://${chain}.infura.io`,
  apiHost = `https://${chain}.xeggo.io`,
  claimHost = 'https://claim.xeggo.io'
})

xeggo SDK constructor takes following params:

  • Required params:
    • xeggoMasterAddress - xeggo master address
    • factoryAddress - xeggo factory contract address

You can use the factory contract deployed on Mainnet, Ropsten, Rinkeby, Goerli and Kovan at 0xBa051891B752ecE3670671812486fe8dd34CC1c8

  • Optional params:
    • chain - Chain name, Currently supported chains are 'mainnet', 'ropsten', 'rinkeby', 'goerli' and 'kovan'. Will use 'mainnet' by default
    • jsonRpcUrl - JSON RPC URL to Ethereum node. Will use ${chain}.infura.io by default
    • apiHost - xeggo Relayer Service API host. Will use ${chain}.xeggo.io by default
    • claimHost - Claiming page url host. Will use claim.xeggo.io by default

With the SDK initialized you now need to take the following steps to distribute claimable xeggos:

Precompute proxy address

let proxyAddress = xeggoSDK.getProxyAddress((campaignId = 0));

This function precomputes the proxy address for each campaign.

⚠️ If you are integrating one-to-one xeggos you should always use campaignId = 0

Approve ERC20 tokens to proxy address

const txHash = await xeggoSDK.approve({
  signingKeyOrWallet,
  proxyAddress,
  tokenAddress,
  tokenAmount,
});

This function will approve tokenAmount tokens to provided proxy address

Approve ERC721 tokens to proxy contract

const txHash = await xeggoSDK.approveERC721({
  signingKeyOrWallet,
  proxyAddress,
  nftAddress,
});

This function will approve all NFTs to provided proxy address

Top-up proxy address with ETH

const txHash = await xeggoSDK.topup({
  signingKeyOrWallet,
  proxyAddress,
  weiAmount,
});

This function will topup the provided proxy address with weiAmount ethers

Top-up and deploy proxy contract

const txHash = await xeggoSDK.deployProxy({ signingKeyOrWallet, campaignId = 0, weiAmount })

This function will deploy a proxy contract for a given campaign id and top it up with weiAmount provided

Generate links

Generate link for ETH or ERC20

const {
  url,
  linkId,
  linkKey,
  xeggoSignerSignature
} = await xeggoSDK.generateLink({
    signingKeyOrWallet, // Signing private key or ethers.js Wallet instance
    weiAmount, // Amount of wei per claim
    tokenAddress, // ERC20 token address
    tokenAmount, // Amount of ERC20 tokens per claim
    expirationTime = 12345678910, // Link expiration time
    campaignId = 0, // Campaign id
  })

This function will generate link for claiming ETH or any ERC20 token and return the following params url, linkId, linkKey, xeggoSignerSignature

Generate link for ERC721

const {
  url,
  linkId,
  linkKey,
  xeggoSignerSignature
} = await xeggoSDK.generateLinkERC721({
    signingKeyOrWallet, // Signing private key or ethers.js Wallet instance
    weiAmount, // Amount of wei per claim
    nftAddress, // ERC721 token address
    tokenId, // Token id
    expirationTime = 12345678910, // Link expiration time
    campaignId = 0, // Campaign id
  })

This function will generate link for claiming ERC721 token and return the following params url, linkId, linkKey, xeggoSignerSignature

Claim links

Claim ETH or ERC20

const txHash = await xeggoSDK.claim({
    weiAmount, // Amount of wei per claim
    tokenAddress, // ERC20 token address
    tokenAmount, // Amount of ERC20 tokens to claim
    expirationTime = 12345678910, // Link expiration time
    linkKey, // Link ephemeral key
    xeggoSignerSignature, // Signature of xeggo signer
    receiverAddress, // Address of receiver
    campaignId = 0, // Campaign id
}

This function will claim ETH or ERC20 token by making a POST request to server endpoint. Make sure the server is up by running yarn server.

Claim ERC721

const txHash = await xeggoSDK.claim({
    weiAmount, // Amount of wei per claim
    nftAddress, // ERC721 token address
    tokenId, // Token id to claim
    expirationTime = 12345678910, // Link expiration time
    linkKey, // Link ephemeral key
    xeggoSignerSignature, // Signature of xeggo signer
    receiverAddress, // Address of receiver
    campaignId = 0, // Campaign id
}

This function will claim ETH or ERC20 token by making a POST request to server endpoint. Make sure the server is up by running yarn server.

Subscribe for Claimed events

await xeggoSDK.subscribeForClaimedEvents(proxyAddress, callback);

Subscribe for ClaimedERC721 events

await xeggoSDK.subscribeForClaimedERC721Events(proxyAddress, callback);

Stay in Touch