> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Export contract events to Postgres

> Walk through the Goldsky CLI wizard to build a Mirror pipeline that decodes contract events and streams them into a Postgres database sink.

<Warning>
  Mirror is Goldsky's previous-generation pipeline product. If you're building a new pipeline, use [Turbo](/turbo-pipelines/introduction) instead. See the [Mirror vs. Turbo comparison](/mirror-vs-turbo), or the [migration guide](/turbo-pipelines/migrate-from-mirror) if you have an existing Mirror pipeline.
</Warning>

The `goldsky` CLI provides wizard to create pipelines. Based on the input you provide, the CLI generates a pipeline definition for you behind the scenes.

To create a new pipeline with the wizard, use the following command:

```shell theme={null}
goldsky pipeline create <your-pipeline-name>
```

## What you'll need

1. An idea of the data you're interested in indexing (eg. contract address)
2. A destination sink to write your data to

## Walkthrough

<Steps>
  <Step title="Use the CLI wizard">
    In this example, we will create a pipeline that indexes Bored Ape Yacht Club contract events to a NeonDB (Postgres) database. This will include all transfers and other auxillary events associated to that address, with our ethereum decoded dataset as the source.

    Initiate the wizard:

    ```shell theme={null}
    goldsky pipeline create bored-ape-transfers
    ```

    1. **Select a Data Source**: Choose *Direct Indexing*.
    2. **Choose Data Type**: Opt for *Ethereum - Decoded Logs*.
    3. **Data Processing Time**: Pick *Process data from the time this pipeline is created*.
    4. **Additional Sources**: Select *No* when asked to add more sources.
    5. **Data Filtering**: Choose *Yes, filter the indexed on-chain data*.
    6. **Contract Address**: Enter the [Bored Ape Yacht Club](https://boredapeyachtclub.com) contract address, `0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d`, when prompted.
    7. **Transformation**: Choose *No* when asked to add another transform.
    8. **Set Up Sink**: Choose *Postgres*. Remember to have a
       Postgres [Neon DB](https://neon.tech)instance to connect to.
    9. **Set Up Secret**: Connect your sink by following the prompts or selecting an existing one. This information is stored in your Goldsky account.
    10. **Choose Schema**: Choose *Yes* to select default 'public' schema or choose your preferred alternative schema.
    11. **Map Data to Sink Tables**: Select *Yes* when asked to automatically map data to sink tables. Choose *No* if you wish to customize the table name.
    12. **Additional Sinks**: Select *No* when asked to add another sink.
  </Step>

  <Step title="Monitor the pipeline">
    Upon successful completion of these steps, an active pipeline is created. Data should start appearing in your database shortly. Monitor the table that is displayed. "RUNNING" status should appear after a minute or two. To monitor progress at any time, use:

    ```shell theme={null}
    goldsky pipeline monitor bored-ape-transfers
    ```
  </Step>

  <Step title="Get the pipeline's definition">
    You can get the generated pipeline definition using:

    ```shell theme={null}
    goldsky pipeline get-definition bored-ape-transfers
    ```
  </Step>

  <Step title="Explore">
    For a full list of all available commands, use:

    ```shell theme={null}
    goldsky pipeline --help
    ```
  </Step>
</Steps>

Can't find what you're looking for? Reach out to us at [support@goldsky.com](mailto:support@goldsky.com) for help.


## Related topics

- [Decode contract events](/mirror/guides/decoding-contract-events.md)
- [Real-time payment reconciliation](/solutions/real-time-reconciliation.md)
- [evm Smart Contracts](/compose/context/evm/contracts.md)
- [Stream DEX trades to a database with Mirror](/mirror/guides/stream-DEX-trades.md)
- [PostgreSQL aggregation](/turbo-pipelines/sinks/postgres-aggregate.md)
