Coder Social home page Coder Social logo

zawadiproject / metatx-standard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bcnmy/metatx-standard

0.0 1.0 0.0 126 KB

Repository contains generalized meta transaction standard that can be added to any smart contract to allow Meta Transactions from any externally-owned (key-based) account.

License: GNU General Public License v3.0

HTML 17.64% CSS 29.90% JavaScript 52.46%

metatx-standard's Introduction

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 Ropsten)

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
  3. (Optional) Use msgRelayer() method to get the relayer address who paid for transaction gas fees That's it. Pretty simple

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.

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

metatx-standard's People

Contributors

tomarsachin2271 avatar stevegachau avatar divyan73 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.