https://github.com/parv3213/biconomy-poc
https://github.com/parv3213/biconomy-poc
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/parv3213/biconomy-poc
- Owner: parv3213
- License: mit
- Created: 2021-06-25T06:50:08.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-25T06:51:52.000Z (almost 5 years ago)
- Last Synced: 2025-02-22T19:49:16.412Z (over 1 year ago)
- Language: JavaScript
- Size: 217 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Generalized Meta Transaction
Repository containing a gas cost effective standard for meta transaction to be used by any contract to enable native meta transaction feature on any function.
The approach support signed typed messages so that while signing the data on client side user see a human readable message instead of scary hex string.
You can see the LIVE DEMO Here(works on Kovan)
The standard is the result of initiative by metamask here https://medium.com/metamask/announcing-a-generalized-metatransaction-contest-abd4f321470b
Biconomy was selected as one of the finalist in the hackathon. Read here
How do i use this in my Smart Contracts?
1. Inherit EIP712MetaTransaction contract
2. Use msgSender() method where ever you were using msg.sender
How do i use this in my client code?
In order to execute meta transactions you just need to call
executeMetaTransaction(address userAddress, bytes memory functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV)
inherited from EIP712MetaTransaction.sol
userAddress => externally owned address of the user eg the user address in his metamask wallet
functionSignature => ABI encoding of function name with its parameter. Use web3 encodeABI method here
sigR => 32 bytes r part of the signature
sigS => 32 bytes s part of the signature
sigV => integer v part of the signature
r,s,v can be calculated using web3 getSignatureParameters utility method.
Since this standard supports EIP-712 so signature parameters should be generated using eth_signTypedData_v3 or eth_signTypedData_v4 JSON RPC method.
How to Run test cases
Setup
Rename .secret.example to .secret and add 12 word mnemonic string in the first line
NOTE: Make sure you have nodejs version > 12.0.0
1. Hardcode the `chainId()` at line 28 in EIP712Base.sol to the specific network Id e.g 42 for Kovan etc.
2. Similarly change the same networkId as above in `EIP712MetaTransaction.test.js` at line 146.
3. Run `npm install` command to install all the dependencies
4. Run `ganache-cli` in separate cmd/terminal to run ganache client
5. At last, Run `npm run test` to run all the test cases.
How to get test coverage
1. Hardcode the `chainId()` at line 28 in EIP712Base.sol to the specific network Id e.g 42 for Kovan etc.
2. Similarly change the same networkId as above in `EIP712MetaTransaction.test.js` at line 146.
3. Run `npm install` command to install all the dependencies
4. Run `ganache-cli` in separate cmd/terminal to run ganache client
5. At last, Run `npm run coverage` to get test coverage report
Check out example front-end code here and example solidity code here
This repository is basic implementation of Native Meta Transactions. This reposiory will be updated as per the EIP-1776 to implement native meta transactions with support of batching, transaction expiry etc