USDC now available on Flow!

Dear Flow Community,

We have some very exciting news: USDC is now available on Flow!

Read on for more information, or jump straight to the USDC docs here to get started.

What is USDC?

USDC (USD Coin) is the world’s leading digital US dollar stablecoin, fully collateralized 1-for-1 with USD. This means that for every 1 USDC token in circulation there is USD $1 held in collateral. Fun fact: USDC has supported about $1.6 trillion in transactions over the past year.

Why is this important?

USDC opens the doors for apps built on Flow to interact seamlessly with hundreds of companies, products and services, including digital wallets, exchanges, DeFi protocols, savings, lending and payment services. More specifically:

  1. Native integration: Web3 apps built on Flow can now interact with USDC natively on-chain using USDC’s “Fiat Token” Smart contract, based on the standard Fungible Token interface (go to the bottom of this post for Testnet and Mainnet addresses)
  2. Cross-chain compatibility: since USDC is also available on other blockchains such as Ethereum, it’s now easier than ever before to reach more users and deepen connections with creators. Circle’s accounts API makes funding accounts chain agnostic.
  3. Industry-standard fiat onramp: aside from the native smart contracts, Circle, the company operating USDC, also offers a cross-chain payments API, making it easy to transact across card, ACH and wire transfers, alongside crypto payments.
  4. DeFi: USDC is the most commonly used stable asset in the DeFi space, providing safe and convenient access to highly liquid crypto capital markets, further enabling the growth of DeFi on Flow.

How do I get started?

The fastest way to get started with USDC is to sign up for a sandbox account. This will help you get familiar with the APIs and how to move funds between Flow and a cross-chain USDC Circle Wallet.

Sign up here: https://my-sandbox.circle.com/signup.

Demo

Just to give you a quick teaser, I will show how to move USDC funds between Flow and your cross-chain Circle USDC Wallet (and back). To follow along, you’ll need to obtain an API key for the sandbox environment. To do this, simply create an account and generate a new key in settings - it only takes a few seconds. Get an API key here.

Note: things may change/break, so please check the official documentation for the most up to date information!

Moving USDC Funds from Flow to a Circle Wallet

1. Create a new Wallet

For the purpose of this quick demo, we’ll create a brand new wallet to receive the external funds coming from Flow. You can create new hosted wallets using the create wallet endpoint. Use the command below (create your own idempotency key).

cURL Request

# Replace ${YOUR_API_KEY} with your API key
curl -H 'Content-type: application/json' \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -X POST https://api-sandbox.circle.com/v1/wallets \
  --data '{"idempotencyKey": "4ddef365-f2fc-4a56-95f5-a214c84ba8f4"}'

Response Body

{
  "data":{
    "walletId":"1000005062",
    "entityId":"7cbdedb1-d526-46b4-af12-4162a002eb9c",
    "type":"end_user_wallet",
    "balances":[]
  }
}

2. Create a deposit address

Wallets themselves are not tied to specific blockchains. Instead, we generate deposit addresses for wallets, allowing us to receive transfers from different chains.

To continue with our example and create a new Flow deposit address, use the generate new address endpoint. You have to properly specify the currency (USD) and chain (FLOW) attributes to ensure the API generates a USDC deposit address for the Flow blockchain.

Create a deposit address for your wallet using the command below.

cURL Request

# Replace ${YOUR_API_KEY} with your API key
# Replace ${WALLET_ID} with the wallet id from the previous step
curl -H 'Accept: application/json' \
  -H 'content-type: application/json' \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -X POST --url https://api-sandbox.circle.com/v1/wallets/${WALLET_ID}/addresses \
  --data '{"idempotencyKey": "ed9a7b3b-b45f-4262-a8aa-8dfee5a4f31b", "currency": "USD", "chain": "FLOW"}'

Response body

{
  "data":{
    "address":"0xb31a443a15e890fb",
    "currency":"USD",
    "chain":"FLOW"
  }
}

3. Receive the funds

Warning! Do NOT send real / live USDC to addresses generated in the sandbox environment as your funds might be permanently lost.

Next, it’s time to transfer the funds from the Flow blockchain. Circle’s sandbox environment is connected to the Flow Testnet network, so you can send USDC from a Testnet wallet into your Circle hosted wallet. Visit USDC on Testing Networks to learn more about support on other blockchains.

If you need to fund your account with USDC, you can obtain some USDC for testing by using a USDC faucet. Go to usdcfaucet.com and make sure you choose the FLOW button. Paste the deposit address you created above (be very careful to not miss any characters) and hit Submit.

4. Check the status of the transfer

You can use the retrieve transfers endpoint to find transfers that are destined to the wallet you created earlier. You can use it as in the command below.

cURL Request

# Replace ${YOUR_API_KEY} with your API key
# Replace ${WALLET_ID} with the wallet id from the previous step
curl -H "Authorization: Bearer ${YOUR_API_KEY}" \
     -X GET https://api-sandbox.circle.com/v1/transfers?destinationWalletId=${WALLET_ID}

Response Body

{
  "data":[
    {
      "id":"9f6362f4-a3d2-396e-a1eb-b628ec3a29b2",
      "source":{
        "type":"blockchain",
        "chain":"FLOW"
      },
      "destination":{
        "type":"wallet",
        "id":"1000005062",
        "address":"0xb31a443a15e890fb"
      },
      "amount":{
        "amount":"1.00",
        "currency":"USD"
      },
      "transactionHash":"6dd4144cb1593c08e1dd13c12278c2b21cdfd8fc66edbb32153ad1fdbe7552a6",
      "status":"running",
      "createDate":"2022-01-10T18:50:06.202Z"
    }
  ]
}

You can look up the transactionHash on Flow Testnet Explorer.

Once the status changes to complete (and only once it does so), Circle will credit the receiving wallet with the value of the transfer. Refer to Circle’s confirmations guide to learn about block confirmation requirements for different chains.

Congratulations! We have successfully received USDC using Circle’s Accounts API. Now let’s see how to move funds from our newly created wallet to a Flow address. It only takes 1 API call!

Moving USDC funds from a Circle Wallet to a Flow Address

1. Send funds

With our newly funded Wallet (which can also be funded from other blockchains, such as Ethereum USDC), we can now initiate a USDC transfer to a Flow address with the command below which uses the create transfer endpoint.

cURL Request

# Replace ${YOUR_API_KEY} with your API key
# Replace ${YOUR_WALLET_ID} with your master wallet id
# Replace ${YOUR_DEPOSIT_ADDRESS} with your blockchain address
curl -H 'Accept: application/json' \
  -H 'Content-type: application/json' \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -X POST https://api-sandbox.circle.com/v1/transfers \
  --data '{"idempotencyKey": "fbba9d81-72f1-4bf8-97c8-99f1f28995e2", "source": {"type": "wallet", "id": "${YOUR_WALLET_ID}"}, "destination": {"type": "blockchain", "address": "${YOUR_DEPOSIT_ADDRESS}", "chain": "FLOW"}, "amount": {"amount": "1.00", "currency": "USD"}}'

Response Body

{
  "data":{
    "id":"9dd86dfe-72e8-4182-9573-04196cc7d6cb",
    "source":{
      "type":"wallet",
      "id":"1000005062"
    },
    "destination":{
      "type":"blockchain",
      "address":"0xb31a443a15e890fb",
      "chain":"FLOW"
    },
    "amount":{
      "amount":"1.00",
      "currency":"USD"
    },
    "status":"pending",
    "createDate":"2022-01-11T20:31:39.507Z"
  }
}

That’s it! Now let’s check the status of the transfer.

2. Check the status of the transfer

Again, you can use the get transfer endpoint to retrieve details about the status of the transaction. You can use it as in the command below.

cURL Request

# Replace ${YOUR_API_KEY} with your API key
# Replace ${TRANSFER_ID} with the id of the transfer you created earlier
curl -H "Authorization: Bearer ${YOUR_API_KEY}" \
     -X GET https://api-sandbox.circle.com/v1/transfers/${TRANSFER_ID}

Response Body

{
  "data":{
    "id":"9dd86dfe-72e8-4182-9573-04196cc7d6cb",
    "source":{
      "type":"wallet",
      "id":"1000005062"
    },
    "destination":{
      "type":"blockchain",
      "address":"0xb31a443a15e890fb",
      "chain":"FLOW"
    },
    "amount":{
      "amount":"1.00",
      "currency":"USD"
    },
    "transactionHash":"b51bb89d3b6400fa0fe664adb9f161c92ade97a07b13ed08b9d04be12d403c5d",
    "status":"complete",
    "createDate":"2020-09-23T21:35:03.563Z"
  }
}

Flow transactions are very fast, so it shouldn’t be long before the status of the transfer shows as “complete”.

That’s it! Keep in mind this was just a teaser, I recommend you go through the official documentation following the links below. Happy building!

Update 14/02/22: Check this codesandbox for an example of how to use USDC via FCL (i.e. setup a FiatToken vault and checking for the account balance), based off of the official repo.

Useful Links

Documentation

Flow USDC Contract Addresses

5 Likes