document the relay

This commit is contained in:
Michele Balistreri 2020-05-19 09:22:23 +03:00
parent cb6762d5b7
commit 3e0ee71891
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
1 changed files with 32 additions and 1 deletions

View File

@ -63,4 +63,35 @@ In case of NFT, the NFT must belong to the owner of the bucket and they will be
## relay ## relay
TBD A small HTTP server relaying accepting redeem transactions, signing them and submitting to the network. It allows dApps devs to provide gas abstraction for redeem transactions. The dApp communicates with the relay over a simple HTTP interface. To work it requires the private key to an account owning ETH in order to pay for gas.
### General usage & options
You launch the script with
`node scripts/create-redeemable.js <options>`
The options are
`--endpoint`: the address of the RPC endpoint. The client as an empty origin so make sure to start the Ethereum node as needed. For ws, you can just start it with --wsorigins="*". The default value is ws://127.0.0.1:8546. You can use Infura if desired.
`--sender`: the address signing and sending the transactions. This account will pay for gas. **THIS ACCOUNT MUST BE ALREADY UNLOCKED**. If not specified, accounts[0] is used. Also in this case, the account must be unlocked. Ignored if --account is used.
`--account`: the path to a JSON encoded private key. If this is specified, sender will be ignored. Use this if your endpoint is Infura or similar. You do not need a local node in this case. You also need to specify --passfile. This is option is ***required*** if you are using Infura.
`--passfile`: the path to a file storing the password for the JSON encoded private key. Always used with --account.
`--bucket-list`: a file containing a list of bucket addresses one per line. Only transactions to these addresses will be accepted
`--bucket`: same as above, but instead a single address is provided on the command line directly.
### HTTP interface
The http interface is very simple
* `POST /redeem`: signs and forward redeem transactions, paying for the gas. It returns a JSON with a single key `tx` containing the transaction hash. Accepts a JSON containing 3 keys:
1. `bucket`: the bucket address. If this address is not in the list of allowed recipients the call will fail
2. `message`: the entire content of the Redeem message
3. `sig`: the signature generated by Keycard over the message
* `GET /bucket/:address`: returns 200 if the given address in the list of allowed buckets and 404 if it is not.