Give a customer a stablecoin address on an EVM network
Create a Polygon (or Ethereum, Avalanche) address for a customer, see USDC or USDT arrive, and find the deposit in your ledger.
6 min read
This recipe creates a Polygon, Ethereum or Avalanche address for a customer, shows USDC or USDT arriving, and finds the deposit in your ledger. It is for a remittance app whose users top up their balance by sending USDC from an exchange.
Status. Available for USDC and USDT on polygon, ethereum and avalanche.
Money example
1.
Ada asks for a deposit address. You create a Polygon wallet for her with the address 0xc47B2D22812ee674Ee5182320FCCA83854f21962.
2.
Ada withdraws 250 USDC from her exchange, picks the Polygon network and pastes that address.
3.
Gravv sees 250 USDC arrive, records a crypto_funding row of 250 for Ada, and sends you inflow.onchain.completed.
4.
Her wallet shows USDC 250.000000.
Before you start
•
The customer exists, and GET /v1/customers/{customer_id} returns 200 for its id. Gravv does not check customer_id when it creates a wallet, so a typo creates a wallet that belongs to no customer.
•
A scoped key needs account:create.
•
If you want the deposit webhook, register your webhook URL in the Dashboard.
Find out what is required
No API call lists the networks and coins for wallets. Pick a network and coin that the sender's exchange supports from Supported networks and coins.
network
USDC
USDT
polygon, ethereum, avalanche
Available
Available
Steps
1. Create the wallet
Each call with a new Idempotency-Key creates a new wallet. Keep the key with your own record, and reuse it only if you retry after a timeout.
The response includes the address, so there is nothing to poll. Store id and address exactly as returned. EVM addresses come back in mixed (checksum) case, and the wallet_address filter matches case-sensitively. Show Ada the address with the network, for example "Polygon only". Gravv sends no webhook when it creates the wallet.
2. Wait for the deposit
When the coins arrive, Gravv sends inflow.onchain.completed.
The coin is USDC or USDT. Read asset_symbol when it is present, because asset can be the token's contract address.
•
blockchain_network is the wallet's network.
•
Gravv also sends this event for other tokens that land on the address, such as a spam token. Gravv records only USDC and USDT on the networks above as deposits.
•
transaction_id here is <network>:<hash>, not the id of a transaction row. Find the row with tx_hash in step 4.
Gravv caches balances. A missing coin means "not read yet", not zero. "stale": true means Gravv has queued a refresh, so read again a few seconds later.
4. Find the row in your ledger
The tx_hash filter needs an exact match, so send the hash exactly as the event shows it.
The row is transaction_typecrypto_funding, directionin, statuscompleted, with the wallet's id as receiving_account_id. If Gravv does not record the coin or network as a deposit, there is no row.
What can go wrong
Response
Why
Fix
400 missing or invalid customer_id
customer_id is missing
Send the customer's id
400 missing or invalid network
network is missing
Send a network from the table
400 network must be one of the following values: …
The network is unknown or not lower case, such as Polygon
Send a lower-case network from the table
400 Network not supported: tron
Gravv refuses customer wallets on tron
Use a network from the table
400 invalid wallet_type "treasury": must be "customer" or "master"
wallet_type has a wrong value
Leave it out. It defaults to customer
400 internal server error
customer_id is not a UUID, or name is over 255 characters
Fix it and retry with a new key
400 service unavailable
A short outage
Retry with a new key
400 missing idempotency key in request headers
The Idempotency-Key header is missing
Add one
422 idempotency_key_reused
You reused a key with a different body
Use a new key for a new wallet
403 with required_any["account:create"]
The scoped key lacks the permission
Use a key whose role has account:create
Two wallets for one customer on one network
You made two calls with two different keys
Use one key per wallet you mean to create
A COMPLETED event but no row
Gravv does not record the coin or network as a deposit
A sandbox key creates test-network wallets. On EVM sandbox wallets, the USDC balance is the sandbox test dollar, so USDC from a public faucet does not show there. Adding test dollars to a standalone EVM wallet through the API is Not yet available. To test money arriving, use a simulated deposit on an account, or use a faucet with a Stellar or Solana wallet. See Fund wallets during testing.