|
| 1 | +# Request Network TRON Substreams |
| 2 | + |
| 3 | +This package contains a Substreams module for indexing ERC20FeeProxy payment events on the TRON blockchain. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The module indexes `TransferWithReferenceAndFee` events from the deployed ERC20FeeProxy contracts: |
| 8 | + |
| 9 | +- **Mainnet**: `TCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fd` |
| 10 | +- **Nile Testnet**: `THK5rNmrvCujhmrXa5DB1dASepwXTr9cJs` |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +1. **Rust toolchain** with `wasm32-unknown-unknown` target: |
| 15 | + |
| 16 | + ```bash |
| 17 | + rustup target add wasm32-unknown-unknown |
| 18 | + ``` |
| 19 | + |
| 20 | +2. **Substreams CLI**: |
| 21 | + |
| 22 | + ```bash |
| 23 | + brew install streamingfast/tap/substreams |
| 24 | + ``` |
| 25 | + |
| 26 | +3. **bs58 crate** for Base58 encoding (included in dependencies) |
| 27 | + |
| 28 | +## Building |
| 29 | + |
| 30 | +```bash |
| 31 | +# Build the WASM module |
| 32 | +make build |
| 33 | + |
| 34 | +# Generate protobuf types |
| 35 | +make protogen |
| 36 | + |
| 37 | +# Package for deployment |
| 38 | +make package |
| 39 | +``` |
| 40 | + |
| 41 | +## Running Locally |
| 42 | + |
| 43 | +```bash |
| 44 | +# Run with GUI for debugging |
| 45 | +make gui |
| 46 | + |
| 47 | +# Run and output to console |
| 48 | +make run |
| 49 | +``` |
| 50 | + |
| 51 | +## Deployment |
| 52 | + |
| 53 | +### Deploy as Substreams-powered Subgraph |
| 54 | + |
| 55 | +1. Build and package the Substreams module: |
| 56 | + |
| 57 | + ```bash |
| 58 | + make package |
| 59 | + ``` |
| 60 | + |
| 61 | +2. Deploy to The Graph: |
| 62 | + ```bash |
| 63 | + graph deploy --studio request-payments-tron |
| 64 | + ``` |
| 65 | + |
| 66 | +### Subgraph Endpoints |
| 67 | + |
| 68 | +Once deployed, the subgraph will be available at: |
| 69 | + |
| 70 | +- **Mainnet**: `https://api.studio.thegraph.com/query/67444/request-payments-tron/version/latest` |
| 71 | +- **Nile Testnet**: `https://api.studio.thegraph.com/query/67444/request-payments-tron-nile/version/latest` |
| 72 | + |
| 73 | +## Module Details |
| 74 | + |
| 75 | +### `map_erc20_fee_proxy_payments` |
| 76 | + |
| 77 | +Extracts payment events from TRON blocks: |
| 78 | + |
| 79 | +**Input**: `sf.tron.type.v1.Block` |
| 80 | + |
| 81 | +**Output**: `request.tron.v1.Payments` |
| 82 | + |
| 83 | +**Fields extracted**: |
| 84 | + |
| 85 | +- `token_address` - TRC20 token contract address |
| 86 | +- `to` - Payment recipient |
| 87 | +- `amount` - Payment amount |
| 88 | +- `payment_reference` - Indexed payment reference (hex) |
| 89 | +- `fee_amount` - Fee amount |
| 90 | +- `fee_address` - Fee recipient |
| 91 | +- `from` - Sender address |
| 92 | +- `block` - Block number |
| 93 | +- `timestamp` - Block timestamp (Unix seconds) |
| 94 | +- `tx_hash` - Transaction hash |
| 95 | +- `contract_address` - ERC20FeeProxy contract address |
| 96 | + |
| 97 | +## Testing |
| 98 | + |
| 99 | +```bash |
| 100 | +make test |
| 101 | +``` |
| 102 | + |
| 103 | +## License |
| 104 | + |
| 105 | +MIT |
0 commit comments