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

@usher.so/campaigns

v0.0.5

Published

Usher Campaigns is a package that contains logic to support the creation of a Campaign on Usher.

Downloads

7

Readme

@usher.so/campaigns

Usher Campaigns is a package that contains logic to support the creation of a Campaign on Usher.

A Campaign is comprised of three components.

  1. A mutable doc (JSON) on the Campaign Advertiser
  2. A mutable doc on Campaign Details that do not affect the reward/event mechanisms.
  3. An immutable doc that references the mutable docs, as well as includes data related to conversion events and rewards.

Features

  1. Create Advertiser Doc
    The Advertiser Schema:

    {
    	"name": "Advertiser Name",
    	"icon": "https://url_to.com/icon.png",
    	"description": "Service provider for DeFi strategy",
    	"externalLink": "https://advertiser_url.com",
    	"twitter": "https://twitter.com/advertiser_twitter_handle"
    }

    Creating Advertiser Doc:

    import { Campaigns, parseAdvertiserDoc } from "@usher.so/campaigns";
    const advertiser = parseAdvertiserDoc({
    	name: "Advertiser Name",
    	icon: "https://url_to.com/icon.png",
    	description: "Service provider for DeFi strategy",
    	externalLink: "https://advertiser_url.com",
    	twitter: "https://twitter.com/advertiser_twitter_handle",
    });
    const campaignsProvider = new Campaigns();
    const ceramicTile = await campaignsProvider.createAdvertiser(
    	advertiser,
    	user_did
    );
  2. Create Campaign Details Doc
    The Campaign Details Schema:

    {
    	"name": "Some new Campaign",
    	"description": "A description for my Campaign",
    	"destination_url": "https://google.com",
    	"external_link": "https://usher.so?ref=test-campaign",
    	"image": "https://usher-pub.s3.amazonaws.com/app/usher-logo-medium.png"
    }

    Creating Campaign Details Doc:

    import { Campaigns, parseAdvertiserDoc } from "@usher.so/campaigns";
    const advertiser = parseAdvertiserDoc({
    	name: "Some new Campaign",
    	description: "A description for my Campaign",
    	destination_url: "https://google.com",
    	external_link: "https://usher.so?ref=test-campaign",
    	image: "https://usher-pub.s3.amazonaws.com/app/usher-logo-medium.png",
    });
    const campaignsProvider = new Campaigns();
    const tile = await campaignsProvider.createCampaignDetails(
    	campaignDetails,
    	user_did
    );
  3. Create a Campaign
    Example Campaign Schema:

    {
    	"chain": "ethereum",
    	"disable_verification": true,
    	"events": [
    		{
    			"strategy": "flat",
    			"rate": 0.1,
    			"description": "Something happens on my website!"
    		}
    	],
    	"reward": {
    		"name": "ChainLink",
    		"ticker": "LINK",
    		"type": "erc20",
    		"address": "0x326C977E6efc84E512bB9C30f76E30c160eD06FB"
    	},
    	"advertiser": "ceramic_document_stream_id",
    	"details": "ceramic_document_stream_id_2"
    }

    To create a Campaign,

    1. you first must deploy the Campaign Doc to Arweave where it resides immutably.
    2. you then must submit the Arweave Transaction ID to the Usher API where it is then indexed.

    These two steps are managed inside the Campaign Module under the createCampaign and indexCampaign methods of the CampaignDoc.

    A sample Campaign on Arweave can be found here:
    https://viewblock.io/arweave/tx/tXMBq2s8WVpi0javfvChBTw5mQqkRaw8msejyGoHHhA

    More information on the purpose of each Campaign property can be found here:
    https://docs.usher.so/advertise-and-grow-your-web3-brand/the-campaign-object

    import { Campaigns, parseCampaignDoc } from "@usher.so/campaigns";
    const campaign = await parseCampaignDoc(campaignJson);
    
    	const campaignsProvider = new Campaigns();
    	const privateKey = await readWallet(walletData); // read private key of wallet from somewhere.
    
    	console.log("Uploading campaign to Arweave...");
    	const transactionId = await campaignsProvider.createCampaign(
    		campaign,
    		privateKey,
    		{
    			bundlrUrl // use a default -- ie. http://node1.bundlr.network,
    			currency, // set a currency -- ie. matic
    		}
    	);
    
    	await sleep(2000);
    	console.log(`Indexing campaign with origin ${transactionId} on Usher...`);
    
    	try {
    		const response = await campaignsProvider.indexCampaign(transactionId);
    		console.log("Indexed successfully!");
    		console.log(JSON.stringify(response.campaign, null, 2));
    	} catch (e) {
    		throw ono("Cannot index Campaign in Usher", e);
    	}

    While Bundlr Network is not required to submit the Arweave payloads, it does remove delays associated to Arweave's block time.

📕 Documentation

Troubleshooting