-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Muhammad-Altabba/QR_PluginWeb3
Qr plugin web3
- Loading branch information
Showing
13 changed files
with
598 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# General | ||
.DS_Store | ||
*.swp | ||
*.orig | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Dependency directories | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm | ||
.coverage | ||
.tool-versions | ||
|
||
# IDE directories | ||
.idea | ||
tmp | ||
|
||
# Distribution directory | ||
.vscode | ||
lib/ | ||
dist/ | ||
tsconfig.tsbuildinfo | ||
|
||
# Unsupported lock files | ||
package-lock.json | ||
|
||
tmp/ | ||
.npmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,122 @@ | ||
# ChainTrust | ||
There are 3 actors in this workflow. | ||
Each of them there are controladed by value at variables. When client seller and deliver have value =1 an automated external method is activated. When deliver completed their process and his state change to 0 a flag is activated to indicate that the workflow has been completed. | ||
There is a flag that change it´s value to 1 that can be used to generate a prof of delivery. | ||
|
||
Instructions: | ||
network : sepolia | ||
|
||
-Compile | ||
-Deploy SC | ||
-Send 0.3 link to contract address | ||
-Execute function to request temperature | ||
-Copy SC address. | ||
-Add SC address to At Address and press on “At Address” | ||
-Request Temperature | ||
# Web3.js QR Code Plugin | ||
|
||
 | ||
 | ||
|
||
This is a [web3.js](https://github.com/web3/web3.js) `4.x` plugin to generate payable QR Codes. | ||
|
||
## Prerequisites | ||
|
||
- :gear: [NodeJS](https://nodejs.org/) (LTS/Fermium) | ||
|
||
## Installation | ||
|
||
```bash | ||
npm i @Themvp07/qr-web3 | ||
``` | ||
## Using this plugin | ||
|
||
### Installing Version `4.x` of `web3` | ||
|
||
When adding the `web3` package to your project, make sure to use version `4.x`. You can append `@4.0.2-dev.af57eae.0` tag to install the latest version of 4 that this plugin was tested with: | ||
|
||
- `npm i -S [email protected]` | ||
- `yarn add [email protected]` | ||
|
||
> **_NOTE_** | ||
> If 4.x was already released, you are good to just use `web3` without appending anything to it. | ||
To verify you have the correct `web3` version installed, after adding the package to your project (the above commands), look at the versions listed in your project's `package.json` under the `dependencies` section, it should contain version 4.x similar to: | ||
|
||
```json | ||
"dependencies": { | ||
"web3": "4.0.2-dev.af57eae.0" | ||
} | ||
``` | ||
### Registering the Plugin with a web3.js Instance | ||
|
||
After importing `QRCodePlugin` from `@Themvp07/qr-web3` and `Web3` from `web3`, register an instance of `QRCodePlugin` with an instance of `Web3` like so: | ||
|
||
```typescript | ||
import { QRCodePlugin } from '@Themvp07/qr-web3'; | ||
import { Web3 } from 'web3'; | ||
|
||
const web3 = new Web3('YOUR_PROVIDER_URL'); | ||
const qrCodePlugin = new QRCodePlugin(); | ||
|
||
web3.registerPlugin(qrCodePlugin); | ||
``` | ||
|
||
More information about registering web3.js plugins can be found [here](https://docs.web3js.org/docs/guides/web3_plugin_guide/plugin_users#registering-the-plugin). | ||
|
||
### Plugin Methods | ||
|
||
#### Get QR Code to transfer ETH in Ethereum Mainnet | ||
|
||
#### `getQrEthereumMainnet` | ||
|
||
```typescript | ||
async getQrEthereumMainnet( | ||
ethMainnetParams: IETHMainnet | ||
): { | ||
QRCode // In base64 format | ||
} | ||
``` | ||
|
||
#### Get QR Code to transfer ETH in Ethereum Testnet | ||
|
||
#### `getQrEthereumTestnet` | ||
|
||
```typescript | ||
async getQrEthereumTestnet( | ||
ethTestnetParams: IETHTestnet | ||
): { | ||
QRCode // In base64 format | ||
} | ||
``` | ||
|
||
#### Get QR Code for transfer Custom ERC20 Token in Ethereum Mainnet | ||
|
||
#### `getQrEthereumMainnetCustomERC20` | ||
|
||
```typescript | ||
async getQrEthereumMainnetCustomERC20( | ||
ethMainnetCustomERC20Params: IETHMainnetCustomERC20 | ||
): { | ||
QRCode // In base64 format | ||
} | ||
``` | ||
|
||
#### Get QR Code for transfer Custom ERC20 Token in Ethereum Mainnet | ||
|
||
#### `getQrEthereumTestnetCustomERC20` | ||
|
||
```typescript | ||
async getQrEthereumTestnetCustomERC20( | ||
ethTestnetCustomERC20Params: IETHTestnetCustomERC20 | ||
): { | ||
QRCode // In base64 format | ||
} | ||
``` | ||
|
||
## Example | ||
```typescript | ||
import { QRCodePlugin } from '@Themvp07/qr-web3'; | ||
import { Web3 } from 'web3'; | ||
|
||
const web3 = new Web3('YOUR_PROVIDER_URL'); | ||
const qrCodePlugin = new QRCodePlugin(); | ||
|
||
web3.registerPlugin(qrCodePlugin); | ||
|
||
const qrData = { | ||
to: '0x7772fb5804c9C60B76C56aBEEb79f2F6d54519C4', // SOME ADDRESS TO TRANSFER | ||
value: '0.1' // SOME VALUE 0.1 ETH | ||
}; | ||
|
||
const qr = await web3.qrcode.getQrEthereumMainnet(qrData); | ||
console.log(qr); | ||
``` | ||
## Useful links | ||
|
||
[base64-to-image-converter](https://codebeautify.org/base64-to-image-converter) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "qr-web3", | ||
"version": "1.0.0", | ||
"description": "A Web3.js 4.x Plugin for creating Payable QR Codes", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "tsc --build", | ||
"test": "jest --config=./test/unit/jest.config.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.2", | ||
"@types/node": "^20.3.0", | ||
"@types/qrcode": "^1.5.0", | ||
"jest": "^29.5.0", | ||
"qrcode": "^1.5.3", | ||
"typescript": "^5.1.3", | ||
"web3": "^4.0.2-dev.af57eae.0" | ||
}, | ||
"peerDependencies": { | ||
"web3": ">= 4.0.2-dev.af57eae.0 < 5" | ||
}, | ||
"dependencies": { | ||
"jest-extended": "^4.0.0", | ||
"ts-jest": "^29.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './types'; | ||
export * from './qrcode_plugin'; |
Oops, something went wrong.