Skip to content

Typescript module to create and parse EMV QR Code. Pix & EthereumTransaction support.

License

Notifications You must be signed in to change notification settings

Guihgo/emvqrcode-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EMV QR Code Tools

Typescript module to create and parse EMV QR Code. Pix & EthereumTransaction support.

Install

yarn add emvqrcode-tools

Usage

Static PixBrCode

import {PixBrCode} from "emvqrcode-tools"

const run = async ()=>{
    const brCode = new PixBrCode({
        pixKey: "PIX_KEY_HERE",
        additionalInfo: "Some message",
        merchantName: "Guilherme Henrique",
        merchantCity: "Sao Paulo",
        postalCode: "086300000",
        transactionAmount: "10.01",
        referenceLabel: "foo123bar"
    })
    console.log(brCode.get())
}

run()

Static EthereumTransactionCode

import { EthereumCode } from "emvqrcode-tools"
import Web3 from "web3"
import { toChecksumAddress, toWei } from "web3-utils"

const run = async () => {
    const web3 = new Web3(new Web3.providers.HttpProvider("https://data-seed-prebsc-1-s3.binance.org:8545"))
    const defaultGas = "21000"
    const from = toChecksumAddress("0xFROM_ADDRESS")
    const to = toChecksumAddress("0xTO_ADDRESS")
    const value = toWei("0.000171")
    const gasPrice = toWei("15", "Gwei")
    const nonce = await web3.eth.getTransactionCount(from, "pending")

    const ethereumCode = new EthereumCode({
        transactionConfig: {
            nonce,
            from,
            to,
            chainId: 97,
            value,
            gas: defaultGas,
            gasPrice,
            data: "0xa9059cbb000000000000000000000000ab518cd35e0cc361fe7687c3cf6b81147aa62d740000000000000000000000000000000000000000000000008ac7230489e80000"
        },
        provider: {
            host: "https://data-seed-prebsc-1-s3.binance.org:8545"
        },
        additionalInfo: "Some message",
        merchantName: "Guilherme Henrique",
        merchantCity: "São Paulo",
        postalCode: "086300000"
    })

    const code = ethereumCode.get()
    console.log(code)

    console.log(EthereumCode.parse(code))

}

run()

References

About

Typescript module to create and parse EMV QR Code. Pix & EthereumTransaction support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published