0.0.14 • Published 2 years ago

@ngx-web3/ui-payment-btn v0.0.14

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Web Component Crypto Payment Button for Web3 Applications

👀 Overview

Simple HTML UI Crypto Payment Button Component that allows your to provide 100% decentralized USD transaction transactions solution with Bitcoin (BTC) Ethereum (ETH), Binance (BNB) or Solana (SOL) token. It includes real-time currency conversion from USD to selected token using Coingecko API. It also includes an optionnal UI parametter to display QRCode and the transaction status. This HTML component is a great way to provide a crypto payment button to your application or website without centralized payment provider.

⚙️ Install

  • Run npm install @ngx-web3/ui-payment-btn

📝 Usage

Angular >=13

  import { Component } from '@angular/core';
  import '@ngx-web3/ui-payment-btn';
  
  @Component({
    selector: 'app-root',
    template: `
      <p>Price: $ {{amount}} USD</p>
      <ngxweb3-payment-btn
          to="0x..."
          symbol="BNB"
          display-error="true"
          [attr.amount]="amount"></ngxweb3-payment-btn>
    `
  })
  export class AppComponent {
    public amount: number = 100;
  }
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
  ],
  providers: [],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }
// angular.json

    "assets": [
      "src/favicon.ico",
      "src/assets",
      {
        "input": "node_modules/@ngx-web3/ui-payment-btn/assets/payment-btn",
        "glob": "**/*",
        "output": "assets/payment-btn"
      }
    ],
    "allowedCommonJsDependencies": [
      "@solana/buffer-layout",
      "bl/BufferList.js",
      "blob-to-it",
      "borsh",
      "bs58",
      "buffer",
      "hamt-sharding",
      "hash.js",
      "it-parallel-batch",
      "jayson/lib/client/browser",
      "p-retry",
      "parse-link-header",
      "rabin-wasm",
      "rpc-websockets",
      "secp256k1",
      "tweetnacl",
      "varint"
    ]

Polyfill

// allow node crypto library to be used in browser
if (window && (window as any).global === undefined) {
  console.log('window.global is undefined');
  (window as any).global = window;
  (window as any).global.process = {
    env: { DEBUG: undefined }
  } as any;
}

Component Options

AttributDescriptionTypeDefaultRequired
chainidNetwork channel id. Refere to Network & ChainId documentation section to select correct valueStringmainnetfalse
toWallet destination adrressString-true
symbolToken symbolString-true
amountUSD Amount to sendNumber-true
display-qrcodeDisplay QR CodeBooleantruefalse
display-errorDisplay error messageBooleanfalsefalse

Note: if chainid is use, it must be the first declared attribut.

Component Events

Event namedescriptionPayload
successSuccess event action{tx: transactionHash}
errorError event action{error: Error}

🔍 Exemples

Real project:

Network & ChainId configuration options

Networkschainid
BTC
mainnet-
testnet-
BNB
mainnet38
testnet61
ETH
mainnet1
ropsten3
rinkeby4
SOL
mainnet-beta55
testnet56
devnet57

Note: User must have an Web3 Wallet provider like metamask or phantom to use this component from web browser.

0.0.14

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago