Skip to content

Commit 7dba63e

Browse files
authored
docs: add comprehensive README documentation (#163)
- Add environment variables documentation with descriptions and defaults - Document complete application workflow from startup to transaction submission - Include building and running instructions - Provide clear overview of the Cardano indexer and reward system Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 2e00cc5 commit 7dba63e

File tree

1 file changed

+79
-1
lines changed

1 file changed

+79
-1
lines changed

README.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,79 @@
1-
# buidler-fest-2024-workshop
1+
# buidler-fest-2024-workshop
2+
3+
A Cardano blockchain indexer and reward system that monitors transactions and automatically sends rewards based on configurable criteria.
4+
5+
## Environment Variables
6+
7+
The application uses environment variables to configure its behavior. You can set these variables in your environment or create a `.env` file in the project root.
8+
9+
### General
10+
- `NETWORK`: Cardano network to use (default: `preprod`)
11+
12+
### Indexer
13+
Use one of the following:
14+
- `INDEXER_TCP_ADDRESS`: TCP address and port of the remote Cardano Node for the indexer
15+
- `INDEXER_SOCKET_PATH`: Socket path of the local Cardano Node for the indexer
16+
17+
### Reward
18+
- `MIN_LOVELACE`: Minimum Lovelace required to trigger a reward (default: `50_000_000`)
19+
- `REWARD_ADDRESS`: Address to send rewards to
20+
- `REWARD_AMOUNT`: Amount of Lovelace to send as a reward (default: `5_000_000`)
21+
- `SOURCE_ADDRESS`: Source address to filter transactions
22+
23+
### Submit
24+
Use one of the following:
25+
- `SUBMIT_TCP_ADDRESS`: TCP address and port of the remote Cardano Node for transaction submission
26+
- `SUBMIT_SOCKET_PATH`: Socket path of the local Cardano Node for transaction submission
27+
- `SUBMIT_URL`: API URL for transaction submission
28+
29+
### TxBuilder
30+
Use one of the following:
31+
- `BLOCKFROST_API_KEY`: Blockfrost API key for UTxO queries
32+
- `KUPO_URL`: Kupo URL for UTxO queries
33+
34+
### Wallet
35+
- `MNEMONIC`: Wallet mnemonic (if not set, will use or generate `seed.txt`)
36+
37+
## Application Workflow
38+
39+
### 1. Startup (`cmd/workshop/main.go`)
40+
- The main entry point is the `main()` function
41+
- Loads configuration from environment variables and `.env` file
42+
- Sets up logging
43+
- Initializes the wallet (loads or generates mnemonic)
44+
- Starts the indexer
45+
46+
### 2. Wallet Setup (`internal/wallet/wallet.go`)
47+
- Loads mnemonic from config or `seed.txt`
48+
- If not present, generates a new mnemonic and writes it to `seed.txt`
49+
- Initializes the wallet for use
50+
51+
### 3. Indexer (`internal/indexer/indexer.go`)
52+
- Creates a pipeline to listen for transaction events on the configured network and addresses
53+
- Filters events for relevant addresses (wallet and reward)
54+
- On transaction events, triggers the transaction builder
55+
56+
### 4. Transaction Builder (`internal/txbuilder/txbuilder.go`)
57+
- Handles transaction events
58+
- Checks if the transaction meets reward criteria (source address, minimum Lovelace, etc.)
59+
- Builds a reward transaction if criteria are met
60+
- Signs the transaction with the wallet keys
61+
62+
### 5. Transaction Submission (`internal/txsubmit/txsubmit.go`)
63+
- Submits the built transaction to the network via TCP, socket, or API, depending on config
64+
65+
## Building and Running
66+
67+
To build the application:
68+
69+
```bash
70+
make build
71+
```
72+
73+
To run the application:
74+
75+
```bash
76+
./workshop
77+
```
78+
79+
The application will run continuously, monitoring the blockchain for transactions and automatically sending rewards when criteria are met.

0 commit comments

Comments
 (0)