Skip to main content
This guide covers how to:

Locate a customer’s smart contract

To enable spending on Rain, customers must deposit collateral into their designated smart contracts. You can retrieve the contract details, including supported tokens, by calling the get issuing user contracts endpoint. Provide the relevant information retrieved from this endpoint to your customers so they can transfer collateral to the given address on the specified blockchain.

Check a customer’s credit limit

Once the smart contract contains collateral, the customer’s credit limit will be updated within minutes. You can check their credit balance and spending limits using the get issuing user balances endpoint. This endpoint will provide:
  • The customer’s current credit limit
  • Any outstanding charges on their account
  • Any balances that are due

Manage admin access

To approve collateral withdrawals, a wallet address must have admin access to the customer’s smart contract. By default, the wallet used during customer signup is an admin of the contract, however, additional admins can be added.

Update a user’s wallet address

If you use a Rain-Managed program, you can update a user’s EVM wallet address even when they have existing collateral contracts on EVM chains. The new wallet must already be an on-chain admin on all of the user’s EVM collateral contracts. To update the wallet address:
  1. Add the new wallet address as an admin on all EVM collateral contracts for the user
  2. Call PATCH /v1/issuing/users/{userId} with the new walletAddress
If the new wallet is not an admin on all contracts, the API returns a 423 Locked error indicating which chains failed verification.
Partner-Managed tenants cannot update wallet addresses when contracts have been deployed for their program. The API returns a 423 Locked error in this case.

[Sandbox] Mint Test Tokens for Collateral

For testing collateral, you can mint rUSD, a token created for testing purposes. This token can be used as collateral to simulate funding scenarios. See supported networks and minting process in resources tab.

Process a collateral withdrawal

Only an admin wallet on the smart contract can withdraw collateral. However, withdrawals can be made to any address.

Step 1: Request a withdrawal signature

Use the get user withdrawal signature endpoint.
  • Get the token info from the get issuing user contracts response.
  • If the response status is pending, wait the specified number of seconds before retrying.

Step 2: Execute the withdrawal transaction

Use the signature to call withdrawAsset on the smart contract controller. You’ll need the following parameters:

Step 3: Execute with ethers.js

Code examples

V1 Contracts

This example uses the Issuing API and V1 contracts to request a signature and execute the transaction:

V2 Contracts - EVM

V2 contracts require an additional adminSignature and adminSalt, generated by the contract admin: For V2, we renamed the controllerAddress contract to coordinatorAddress which can be obtained from the get issuing user contracts response.

Generating Admin Signature (V2)

Use this helper to generate the required parameters for the withdrawal transaction:

V2 Contracts - Solana

Please find an instruction and code example here