!! 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!
This is a plugin for pretix. This plugin supports both Ethereum and DAI.
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
For DEVcon6 the plugin was extended with some more features like Layer2 support by Rahul. Layer2 will play a significant role in Ethereum. Unfortunately DEVcon6 was delayed due to covid - but we where able to use and this way test via the LisCon ticket sale. As far as we know this was the first event ever offering a Layer2 payment option. In the process tooling like Web3Modal / Checkout that we depend on was improved.
- L2s added!
- A panel was added in the web admin interface to upload a list of addresses to be associated with each ticket order.
- During the checkout process, an address is chosen for each order from the list of remaining addresses created by the address upload process.
- A payment confirmation management command was added that confirms pending
payments based on the address assigned to them during checkout. See the
confirm_payments
section below for details.
- Clone this repository, e.g. to
local/pretix-eth-payment-plugin
. - Create and activate a virtual environment.
- Execute
pip install -e .[dev]
within thepretix-eth-payment-plugin
repo directory. - Setup a local database by running
make devmigrate
. - Fire up a local dev server by running
make devserver
. - Visit http://localhost:8000/control/login in a browser windows and enter
username
admin@localhost
and passwordadmin
to log in. - Enter "Admin mode" by clicking the "Admin mode" text in the upper-right corner of the admin interface to create a test organization and event.
- Follow instructions in Event Setup Instructions
- Under the event, go to Settings -> Plugins -> Payment Providers -> click on Enable under "Pretix Ethereum Payment Provider"
- Next, under Settings, go to Payments -> "ETH or DAI" -> Settings -> click on "enable payment method".
- Next, scroll down and set the values for the following:
- "TOKEN_RATE" - This is a JSON e.g.
i.e.
{"ETH_RATE": 4000, "DAI_RATE": 1}
KEY
=<CRYPTO_SMBOL>_RATE
andVALUE
= value of 1 unit in your fiat currency e.g. USD, EUR etc. For USD, above example says 1 ETH = 4000$. If EUR was chosen, then this says 1 ETH = 4000EUR. - Select the networks you want under the "Networks" option - Choose from Ethereum Mainnet, Optimism, Arbitrum and their testnets.
- "NETWORK_RPC_URLS" - This is a JSON e.g.
i.e.
{ "L1_RPC_URL": "https://mainnet.infura.io/v3/somekeyhere", "Rinkeby_RPC_URL": "...", "RinkebyArbitrum_RPC_URL": "..." }
KEY
=<Network ID>_RPC_URL
andVALUE
= RPC URL. Network IDs can be found in tokens.py
- Under Event, go to Settings -> Upload Wallet Addresses - upload some ethereum addresses
You can now play with the event by clicking on the "Go to Shop" button at the top left (next to the event name)
This plugin includes a django management command that can be used to automatically confirm orders from the Ethereum address associated with each order across all events. 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's an example invocation of this command:
python -mpretix confirm_payments \
--no-dry-run
Note that this doesn't require you to pass any event slug, since it runs for all events at once. It inspects the address that was associated with each order (at
the time the ticket was reserved) to determine if sufficient payments were made
for the order. It may check for an ethereum payment or some kind of token
payment depending on what was chosen during the checkout process. It checks using the RPC URLs that were configured in the admin settings while setting up the event. If no rpc urls were set, then the command gives yet another chance to type in a rpc url (like infura). The --no-dry-run
flag directs the command to
update order statuses based on the checks that are performed. Without this
flag, the command will only display how records would be modified.
For more details about the confirm_payments
command and its options, the
command may be invoked with --help
:
python -mpretix confirm_payments --help
Copyright 2019 Victor (https://github.com/vic-en)
Released under the terms of the Apache License 2.0