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

# gtoken quickstart

> Make your first sandbox deposit into Ground RWA yield using the API and a customer wallet.

Make your first sandbox deposit into Ground RWA yield. Your backend uses the
Ground API to discover a gVault, configure fees and admit a customer wallet.
The customer's wallet sends the deposit transaction.

## Before you start

You need:

* A sandbox API key from the [Ground Developer Portal](https://portal.groundtech.co).
  Keep this key on your backend.
* A customer wallet connected to the chain returned by discovery, with the
  listed funding asset and funds for transaction fees.
* Ethers v5 in your wallet application for the deposit example below.

## 1. Discover your contract

Account setup automatically provisions one USTB and one PRIME gVault for your
sandbox organization. List the available contracts from your backend:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export BASE_URL="https://sandbox.groundtech.co"
export GROUND_API_KEY="<sandbox-api-key>"
curl --fail-with-body "$BASE_URL/v3/gvaults" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

The response lists contracts ready for deposits:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "data": [
    {
      "id": "8f4c52d7-62ab-4db9-a964-92f481f6b851",
      "assetId": "0031d484-d955-4612-b23b-d4d466c5abe6",
      "name": "Ground USTB gVault",
      "chain": "ethereum_sepolia",
      "contractAddress": "0x1111111111111111111111111111111111111111",
      "asset": {
        "symbol": "USDC",
        "contractAddress": "0x2222222222222222222222222222222222222222",
        "decimals": 6
      }
    }
  ]
}
```

The example addresses are illustrative. Select a row from your response and
save its `id` for API calls. Pass the complete row to your wallet application
as `gVault` in step 4. Use its `chain` to connect the customer wallet and its
`asset` to fund the deposit. If `data` is empty, retry while setup completes;
contact Ground if contracts remain unavailable.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export GVAULT_ID="<id-from-discovery>"
```

## 2. Configure your fees (optional)

To charge your customers fees, configure them below. Otherwise, continue to step 3.

Set `FEE_RECIPIENT_ADDRESS` to the wallet that should receive both your
management and performance fee shares. This example sets a 0.20% annual
management fee and a 15% performance fee:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export FEE_RECIPIENT_ADDRESS="<your-fee-recipient-address>"
curl --fail-with-body -X PATCH "$BASE_URL/v3/gvaults/$GVAULT_ID/fees" \
  -H "Authorization: Bearer $GROUND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"feeRecipientAddress":"'"$FEE_RECIPIENT_ADDRESS"'","managementFeePct":0.2,"performanceFeePct":15}'
```

Rates use percentages: `1` means 1%. Omitted fields stay unchanged. See
[configure fees](https://docs.groundtech.co/v3/docs/gtokens/discover-yield-sources.md#3-configure-your-fees)
for fee limits and recipient requirements.

A `200` response with `status: confirmed` means your requested configuration is
already effective. For a `202` response, poll the detail endpoint:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --fail-with-body "$BASE_URL/v3/gvaults/$GVAULT_ID" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

If `feeUpdate.status` is `awaiting_approval`, use its `activityId` with the
[approval API](https://docs.groundtech.co/v3/docs/portfolio-wallets/transaction-approvals.md#approving-an-activity)
and your registered signing key. Continue when `feeUpdate.status` is `confirmed`
and `fees` contains the requested values. If the update fails or a request
times out, read the current state before retrying. A `409 gvault_fee_update_pending`
means another update must finish first.

## 3. Admit the customer wallet

Use the address that will make the deposit and receive the shares:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export CUSTOMER_ADDRESS="<your-customer-wallet-address>"
curl --fail-with-body -X PUT \
  "$BASE_URL/v3/gvaults/$GVAULT_ID/allowlist/$CUSTOMER_ADDRESS" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

Your API key authorizes this call; no request body is needed. Poll the same URL
with `GET` until `allowed` is `true`:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --fail-with-body \
  "$BASE_URL/v3/gvaults/$GVAULT_ID/allowlist/$CUSTOMER_ADDRESS" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

If the request times out, check access with `GET` before retrying the admission.

## 4. Make a deposit

For PRIME on Tempo Moderato, request gTESTUSDC for the admitted customer wallet
from the [sandbox faucet](https://docs.groundtech.co/v3/api-reference/request-sandbox-tempo-usdc.md). Each request
can transfer up to 100 gTESTUSDC:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export FAUCET_IDEMPOTENCY_KEY="$(uuidgen)"
curl --fail-with-body "$BASE_URL/v3/sandbox/faucets/tempo-usdc" \
  -H "Authorization: Bearer $GROUND_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $FAUCET_IDEMPOTENCY_KEY" \
  -d '{"address":"'"$CUSTOMER_ADDRESS"'","amount":"5"}'
```

Save the returned `id` and check its status until it is `confirmed`:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export FAUCET_REQUEST_ID="<id-from-faucet-response>"
curl --fail-with-body "$BASE_URL/v3/sandbox/faucets/tempo-usdc/$FAUCET_REQUEST_ID" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

Keep the same idempotency key when retrying the request. If the transfer remains
pending, continue checking its status. If it fails, contact Ground with the
request ID and `failureCode` before requesting another transfer.

Pass the discovery row to your wallet application without your Ground API key.
The following Ethers v5 function works with both PRIME and USTB organization contracts.
`signer` is the admitted customer's signer on the discovered chain; `assetAmount`
is a decimal string such as `"1"` for one funding token.

```javascript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { ethers } from 'ethers';

async function deposit({ signer, gVault, assetAmount }) {
  const customer = await signer.getAddress();
  const vault = new ethers.Contract(gVault.contractAddress, [
    'function asset() view returns (address)',
    'function deposit(uint256,address,uint256) returns (uint256)',
    'function balanceOf(address) view returns (uint256)',
  ], signer);
  const assetAddress = await vault.asset();
  if (assetAddress.toLowerCase() !== gVault.asset.contractAddress.toLowerCase()) {
    throw new Error('Deposit asset does not match discovery');
  }
  const token = new ethers.Contract(assetAddress, [
    'function decimals() view returns (uint8)',
    'function approve(address,uint256) returns (bool)',
  ], signer);
  const assets = ethers.utils.parseUnits(assetAmount, await token.decimals());
  const approval = await token.approve(vault.address, assets);
  await approval.wait();

  const expectedShares = await vault.callStatic.deposit(assets, customer, 1);
  const minShares = expectedShares.mul(9950).div(10000);
  if (minShares.isZero()) throw new Error('Deposit amount is too small');

  const transaction = await vault.deposit(assets, customer, minShares);
  const receipt = await transaction.wait();
  const shareBalance = await vault.balanceOf(customer);
  return { transactionHash: receipt.transactionHash, shareBalance };
}

const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send('eth_requestAccounts', []);
const result = await deposit({
  signer: provider.getSigner(),
  gVault,
  assetAmount: '1',
});
console.log(result.transactionHash, result.shareBalance.toString());
```

The simulation estimates the share output after approval. The submitted deposit
accepts at most 0.5% less than that estimate; choose a tolerance appropriate for
your application. If simulation or submission fails, refresh access, balances
and the quote before retrying. Never treat an approval receipt as a deposit.

The function returns the confirmed transaction hash and the customer's updated
share balance. Store the receipt with the chain and gVault ID.

## Next steps

* [Deposit and redeem onchain](https://docs.groundtech.co/v3/docs/gtokens/deposit-and-redeem.md): choose withdrawal methods by `assetId`.
* [Integrate PRIME on Tempo](https://docs.groundtech.co/v3/docs/gtokens/integrate-tempo-earn.md): follow a complete PRIME deposit and redemption example.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.