Git Product home page Git Product logo

paymaster's Introduction

Paymaster Protocol


Table of Contents

About

Paymaster Protocol is a library designed to provide a standard for achieving sponsored transactions on StarkNet.

Features

A sponsored transaction is a transaction for which the gas fees are not paid by the person executing it but by another person/organism, the payer.

Here, we have designed a PayableAccount contract that can execute call(s) that are already paid. The sponsored transactions are sent to the classic execute endpoint of the payer account contract (classic OZ Account implementation here). The payer forwards the calldata, along with the user's signature, to the executePaid endpoint of the user account contract (PayableAccount implementation).

This endpoint recomputes the transaction hash of the original user transaction and checks it against the provided signature.

The Cairo part of the repo consists of the PayableAccount implementation. The Python part offers a library to generate/sign/invoke sponsored transactions in a easy way.

There are some examples provided in the examples folder.

Getting Started

Prerequisites

Installation

Paymaster Protocol is a Protostar package, which can be installed by checking out the protostar.toml file as well as the .gitmodules file.

Usage

Build

Cairo contracts are built using Protostar :

protostar build

Run

Examples in the examples folder can be run as stand-alone Python scripts.

Test

Unit tests are written in Cairo using Protostar :

protostar test

Integration tests are written in Python using Pytest & Nile :

python -m pytest tests/ --disable-pytest-warnings

Support

Reach out to the maintainer at one of the following places:

Project assistance

If you want to say thank you or/and support active development of this protocol:

  • Add a GitHub Star to the project.
  • Tweet about this repository.
  • Write interesting articles about the project on Dev.to, Medium or your personal blog.

Contributing

First off, thanks for taking the time to contribute! Any contributions you make will benefit everybody else and are greatly appreciated.

Please read our contribution guidelines, and thank you for being involved!

Authors & contributors

For a full list of all authors and contributors, see the contributors page.

Security

This repository follows good practices of security, but 100% security cannot be assured. This repository is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the MIT license.

See LICENSE for more information.

Acknowledgements

  • OpenZeppelin for the contracts and the tests that are used in this repository.
  • Quaireaux for inspiration the open-source side of this repository.

This project follows the all-contributors specification. Contributions of any kind welcome!

paymaster's People

Contributors

pilouche avatar

Stargazers

Geoffrey Moya avatar Darlington Nnam avatar 0xKubitus avatar 0xevolve avatar William avatar Javed Khan avatar Mathieu avatar zarboq avatar Milan Cermak avatar

Watchers

Antoine Roy avatar maxxeth avatar

paymaster's Issues

Any sample_transaction record on testNet?

Hello, I succeeded in declaring and deploying the contract, but the sample transaction failed with the following error:

`[Paymaster] Starting transfer.
Traceback (most recent call last):
File "examples/transaction/sample_transaction.py", line 118, in
asyncio.run(main())
File "/Users/user/.pyenv/versions/3.8.9/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Users/user/.pyenv/versions/3.8.9/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "examples/transaction/sample_transaction.py", line 113, in main
await payer_account.client.wait_for_tx(transfer_paid.transaction_hash)
File "/Users/user/.pyenv/versions/cairo/lib/python3.8/site-packages/starknet_py/net/client.py", line 159, in wait_for_tx
raise TransactionRejectedError(
starknet_py.transaction_exceptions.TransactionRejectedError: Transaction was rejected with following starknet error: Error at pc=0:12:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:161)
Unknown location (pc=0:147)

Error in the called contract (0x10364bdceef999e5d31010b77da996ab821bc3d48b1f3d2340733ce6cbcbe6d):
Error at pc=0:39:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:1398)
Unknown location (pc=0:1351)
Unknown location (pc=0:569)
Error message: argent: multicall 0 failed
Unknown location (pc=0:586)

Error in the called contract (0x6edad3401692041efc2158c2ab2e4e6cb82e9c0b507495720dc584d8d1ceee6):
Error at pc=0:12:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:161)
Unknown location (pc=0:147)

Error in the called contract (0x6edad3401692041efc2158c2ab2e4e6cb82e9c0b507495720dc584d8d1ceee6):
Entry point 0x13191c98b3d11291b45e74659aa39d08d350d3f84c44724c03816269e78c4c7 not found in contract with class hash 0x33434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2..`

my .env is below

`
PAYER_ADDRESS = 0x010364bdceef999E5d31010B77Da996aB821Bc3d48B1F3D2340733ce6cbcbe6D
PAYER_PRIVATE_KEY =xxxx

USER_ADDRESS = 0x06Edad3401692041eFC2158C2AB2e4E6cB82e9C0B507495720DC584D8D1cEee6
USER_PRIVATE_KEY =xxx

ETH_TOKEN_ADDRESS = 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7
RECIPIENT_ADDRESS = 0x062e5Cd6dc105cf3DCc3921EEFDD3bae1134DE6C884A47c121fB453fD9784e42

`

deploy contract here:
https://testnet.starkscan.co/contract/0x04cc39fe4d2636c808ab94d0303b1c0c011acdc5594adb76269954ece3a1615d#overview
declare here:
https://testnet.starkscan.co/tx/0x056c97caece0678d82e383598b82567532bc46ba35e39f9753572f874c34371d

Can you help point out my problem? Or any sample_transaction record on testNet?

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.