/pretix-eth-payment-plugin

An etheruem payment provider plugin for pretix

Primary LanguagePythonOtherNOASSERTION

Pretix Ethereum Payment Provider

Warning

!! This plugin is not ready for 3rd party production use yet. If you want to use it you must really understand the code !! PRs to make it production ready and more eyes on this code are most welcome!

What is this

This is a plugin for pretix. This plugin supports both Ethereum and DAI.

History

It started with ligi suggesting pretix for Ethereum Magicians.

Then it was used for Ethereum Magicians in Paris (shout out to boris for making this possible) - but accepting ETH or DAI was a fully manual process there.

Afterwards boris put up some funds for a gitcoin bounty to make a plugin that automates this process. And nanexcool increased the funds and added the requirement for DAI.

The initial version was developed by vic-en but he vanished from the project after cashing in the bounty money and left the plugin in a non-working state.

Then the idea came up to use this plugin for DevCon5 and the plugin was forked to this repo and ligi, david sanders, piper meriam, rami, Pedro Gomes, and Jamie Pitts brought it to a state where it is usable for DevCon5 (still a lot of work to be done to make this a good plugin). Currently, it is semi-automatic. But it now has ERC-681 and Web3Modal support. If you want to dig a bit into the problems that emerged short before the launch you can have a look at this issue

Development setup

  1. Make sure that you have a working pretix development setup.
  2. Clone this repository, e.g. to local/pretix-eth-payment-plugin.
  3. Activate the virtual environment you created for your local pretix site that was created in step 1.
  4. Execute pip install -e .[dev] within the pretix-eth-payment-plugin repo directory.
  5. Restart your local pretix server. You can now use the plugin from this repository for your events by enabling it in the 'plugins' tab in the pretix site's admin settings.
  6. Head to the plugin settings page to set the deposit address for both Ethereum and DAI.

Automatic payment confirmation with the confirm_payments command

This plugin includes a django management command that can be used to automatically confirm orders from Ethereum transactions and ERC20 token transfers. By default, this command will perform a dry run which only displays payment records that would be modified and why but without actually modifying them. Here are some example invocations of this command:

# Using the pretix module
python -m pretix confirm_payments --event-slug=devcon-5 --no-dry-run

# Using a django manage.py file
python manage.py confirm_payments --event-slug=devcon-5 --no-dry-run

Above, the confirm_payments command uses the --event-slug argument to determine the wallet address to which ticket payments for the devcon-5 event were sent. It then inspects all external and internal transactions sent to the event's wallet address to determine if sufficient payments were made for payment records identified by the payment IDs encoded in the transactions' wei values. It also inspects all token transfer events targeting the event's wallet address for the DAI stablecoin's mainnet contract address. The --no-dry-run flag directs the command to modify and confirm payments identified by transactions and transfers. Without this flag, the command will only display which records would be modified. Alternatively, the same command above could have been invoked as follows:

python manage.py confirm_payments --wallet-address=<devcon-5-wallet-address> --no-dry-run

...where <devcon-5-wallet-address> is replaced with the explicit 0x-prefixed wallet address for the Devcon 5 event.

The confirm_payments command also supports a number of other arguments. Here are some example uses of them:

python manage.py confirm_payments \
    --event-slug=<slug> \
    --token-address=<token-address> \
    --api=blockscout-mainnet \
    --start-block=<start-block> \
    --end-block=<end-block> \

The above command confirms payments for the event identified by <slug> using the ERC20 token at address <token-address> on the Ethereum mainnet queried through Blockscout. It only considers transactions and token transfers that occurred between and within blocks <start-block> and <end-block>. Also, because the --no-dry-run flag is absent, it simply prints the payments that would be confirmed by the command without confirming them.

For more details about the confirm_payments command and its options, the command may be invoked with --help:

python manage.py confirm_payments --help

License

Copyright 2019 Victor (https://github.com/vic-en)

Released under the terms of the Apache License 2.0