---
title: "Track onchain events for PYUSD, PayPal's new stablecoin"
description: "Learn How to Track All of PYUSD's Onchain Transactions Using Custom Webhooks in Seconds"
---

# Track onchain events for PYUSD, PayPal's new stablecoin

On August 7th, 2023 PayPal announced their new stablecoin, PYUSD. Here’s how to use [Custom Webhooks](https://etherscan.io/address/0xe17b8adf8e46b15f3f9ab4bb9e3b6e31db09126e) to stream onchain events in real time for the PYUSD smart contract.

## **How to track onchain PYUSD activity**

Tracking the onchain activity for PayPal’s [PYUSD smart contract](https://etherscan.io/address/0xe17b8adf8e46b15f3f9ab4bb9e3b6e31db09126e), 0xe17b8aDF8E46b15f3F9aB4Bb9E3b6e31Db09126E, using custom Webhooks is a matter of creating a new [GraphQL](https://www.alchemy.com/dapps/graphql) webhook, copying a simple code snippet, and entering in your webhook URL!

### **1. Log into alchemy’s custom webhooks**

Sign up or log into your Alchemy account and [create a new custom webhook](https://dashboard.alchemy.com/signup?a=track-pyusd&redirectUrl=https%3A%2F%2Fdashboard.alchemy.com%2Fnotify). 

<ImageBlock
  src="https://media.alchemy.com/1703818657-create-custom-webhook-on-alchemy.png"
  alt="Alchemy dashboard: creating a new GraphQL custom webhook"
  width={3428}
  height={890}
  caption="Create a GraphQL Webhook from Alchemy's Dashboard"
/>

For more details, follow this [step-by-step guide to set up a custom webhook](https://www.alchemy.com/docs/reference/custom-webhook).

### **2. Paste in the PYUSD code snippet**

Create a new webhook using a blank template. Paste in your webhook URL \(where you want the events to be streamed\).

<ImageBlock
  src="https://media.alchemy.com/1703818693-paste-webhook-url.png"
  alt="Creating a Custom Webhook to Stream Onchain Events for PYUSD"
  width={2696}
  height={1978}
  caption="Creating a Custom Webhook to Stream Onchain Events for PYUSD"
/>

Next, copy and paste this code snippet into your new GraphQL webhook:

<CodeSnippet
  code={`# Get all Approval() events emitted by the PYUSD contract
  {
    block(hash: "0xaaf4228db65eab92357c124ff8f8f1c5da72a04da660e147157cd4dfd8eb44d6") {
      logs(filter: {addresses: ["0xe17b8aDF8E46b15f3F9aB4Bb9E3b6e31Db09126E"], topics: ["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"]}) {
        account {
          address
        }
        topics
        transaction{
          hash
          index
          to{
            address
          }
          from {
            address
          }
          status
        }
      }
    }
  }`}
  language="graphql"
  theme="dark"
/>

Here's what the important parts of

- **Block** **hash** - the reference number of a block in a blockchain
- **Addresses** - the smart contract address for PYUSD's ERC-20 token
- **Topics** - the topic describes the event that the webhook will track

### 3. Start receiving events at your webhook URL

Once published, your webhook URL should start receiving all events emitted by the PYUSD contract.

<ImageBlock
  src="https://media.alchemy.com/1703819003-event-stream-from-pyusd-smart-contract.png"
  alt="Event Stream from the PYUSD Smart Contract"
  width={3456}
  height={1872}
  caption="Event Stream from the PYUSD Smart Contract"
/>

Each transaction that happens using PayPal’s stablecoin will now be accessible to you via JSON. While some may use this data to create a Twitter bot for large transactions, others may find other unique insights!

### **4. Stream to AWS**

Want to ingest, store and retrieve real-time PYUSD blockchain data with a serverless API? Read our [step-by-step guide to stream blockchain data to AWS](https://www.alchemy.com/docs/reference/custom-webhooks-example) in real-time.

## What is PayPal’s stablecoin PYUSD?

PayPal has announced its intentions to become a major bridge between the Ethereum, onchain ecosystem and the traditional fiat system via its new “[PayPal USD](https://www.alchemy.com/dapps/paypal-usd)” stablecoin.  PayPal USD is an ERC-20 token [claimed to be redeemable 1-1 for US Dollars](https://newsroom.paypal-corp.com/2023-08-07-PayPal-Launches-U-S-Dollar-Stablecoin#:~:text=PayPal%20USD%20is%20redeemable%201%3A1%20for%20U.S.%20dollars). The stablecoin is issued by Paxos Trust Company who hold assets in their reserves to back the PYUSD token. 

PYUSD is the only stablecoin that PayPal will support for the time being, making it desirable for PayPal’s customers who want to quickly move on and offchain. PayPal’s new “Checkout with Crypto” feature will also allow customers to spend PYUSD at checkout. 

### What makes PayPal’s PYUSD interesting to track?

While all of Ethereum’s onchain activity is trackable with Custom Webhooks, the introduction of a digital payments giant into the ecosystem marks era. PayPal will support transferring PYUSD from the PayPal app to Ethereum wallets. This, and other transactions occurring with the stablecoin, may provide insightful onchain analysis.
