Configure your backend
Create an API key in Ground Portal → API Keys. Copy it when shown and store it in your backend’s secret manager asGROUND_API_TOKEN. Never expose an API key in browser or mobile code. The
examples use sandbox:
https://production.groundtech.co, a production API key, and stellar as the chain key.
1. Create a wallet for the customer
Create one Portfolio Wallet for each customer. Store the Ground wallet ID on the customer record in your database.your-usdc-yield-source-id with the USDC yield source configured for
your integration. Save the requestId before sending the request. If the
request times out, retry it with the same ID.
Wallet creation is asynchronous. Subscribe to the
portfolio_wallet.status_changed webhook before creating the wallet. Store the
returned wallet ID, then wait for its status to become idle. If a webhook is
delayed or missed, reconcile the state with GET /v2/wallets/{id}. Treat
failed as a provisioning failure.
Stellar setup happens automatically in the background. An idle wallet may
still be preparing its Stellar address. Poll GET /v2/wallets/{id} until
depositAddresses[stellarChain] appears before depositing. Other returned
addresses remain usable during setup.
If your organization controls its Turnkey signing policy, a new Stellar policy
must be approved in the portal before Stellar setup can finish. Ground does not
change that policy during wallet setup. If the address remains absent, check the
portal’s Approvals tab or contact Ground about the required policy release.
For an older wallet without a Stellar deposit address, contact Ground to arrange
setup.
2. Deposit USDC and start earning
Get the customer’s Stellar deposit address from the wallet:portfolio_wallet.deposit.status_changed before initiating the
transfer. When the deposit becomes completed, refresh the wallet and update
the customer-facing balance.
3. Display balances and earnings
Use the customer’s wallet ID to fetch their current balance and yield details:
Dollar values are returned as decimal strings. Refresh the wallet after deposit
and withdrawal updates. You can also refresh it periodically while the customer
is viewing their portfolio.
4. Withdraw USDC to Stellar
Configure transaction approvals for external payouts, which require customer approval. First, preview the USDC withdrawal amount and Stellar destination chain. If the preview looks correct, create the withdrawal with the customer’s destination address and a newrequestId. Save the returned withdrawal ID in your database.
portfolio_wallet.withdrawal.status_changed until the withdrawal is
completed or failed.