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

react-ergo-payments

v1.0.1

Published

React's Ergo Payment Processor

Downloads

5

Readme

This project was based on Nightowl's Connector.

React Ergo Payments

What is this library?

The React Ergo Payments library is an npm package developed to allow clients to pay/subscribe with ERG within your website. It validates and and submits the client's transaction and your website can do all sorts of fun stuff upon success. Including:

  1. Saving the tx into your database and create active subscriptions depending on timestamp
  2. Triggering a purchase request in your online store
  3. Allow users to pay/donate to specific addresses

Built With

Created using React.js version ^17.1.0 and Nautilus.

This package uses WASM, which is not supported by create-react-app (CRA). Follow the guide below to install it in an existing CRA.

Pre-requisites

  • Node.js
    https://nodejs.org/
  • Nautilus^0.4.0
    https://chrome.google.com/webstore/detail/nautilus-wallet/gjlmehlldlphhljhpnlddaodbjjcchai

Installation

  • Install the package:
    npm install react-ergo-payments

If you are using CRA, this workaround is needed:

  1. npm uninstall react-scripts
  2. npm install @craco/craco
  3. npm install wasm-loader
  4. Create a config file named craco.config.js and add this:
  module.exports = {
  webpack: {
    configure: (webpackConfig) => {
      const wasmExtensionRegExp = /\.wasm$/;
      webpackConfig.resolve.extensions.push('.wasm');

      webpackConfig.module.rules.forEach((rule) => {
        (rule.oneOf || []).forEach((oneOf) => {
          if (oneOf.loader && oneOf.loader.indexOf('file-loader') >= 0) {
            oneOf.exclude.push(wasmExtensionRegExp);
          }
        });
      });

      const wasmLoader = {
        test: /\.wasm$/,
        exclude: /node_modules/,
        loaders: ['wasm-loader'],
      };

      addBeforeLoader(webpackConfig, loaderByName('file-loader'), wasmLoader);

      return webpackConfig;
    },
  },
};

Usage

  • Load the package asynchronously into the file/component you want:
  const [component, setComponent] = React.useState();

  useEffect(() => {
    loadLibrary().then(lib => {
      setComponent(lib);
    })
    return () => setComponent();
  }, []);

  async function loadLibrary() {
      return await import("react-ergo-payments");
  }
  • Finally, use the component:
{ component && <component.ErgoForm /> }

Important: Attributes

Currently, you can specify 4 attributes:

  1. receiverWalletAddress the wallet your want your clients to pay to
  2. onSuccess() call back -> this processor triggers onSuccess(txId, valueSent)
  3. price (in ERG)
  4. color (see Nightowl's Connector for examples)

So an example in your real-world store would be:

function onSuccess(txId, valueSent) {
    // do something with this info
}

{ component && 
<component.ErgoForm 
    price={priceInErg} 
    onSuccess={onSuccess} 
    color={"orange"} 
    receiverWalletAddress={"9iPnRh5gaxxxcCQjUq6cT7FaQpRDpKtu"} /> }

Warning: You need specify the receiverWalletAddress or you will send your funds to my default wallet

Contributing

I'm just venturing into blockchain waters for a short time now, so any suggestions and contributions to this open source project are greatly appreciated!

Contact

Filipe Sommer - LinkedIn