Referrals
A Wealth referral is a bytes32 on a vault request. It attributes that deposit or redemption to a referral code. Encode it before you submit or sign. Use bytes32(0) when no code applies.
This value is not used for SoDEX RWA tokens (clob) or CLOB trades. Claim methods (claimDeposit, claimRedeem, claimDelayedRedeem) do not take a referral.
Use the Referral Code shown on sodex.com/referrals. The Wealth API does not return or validate referrals. Encoding checks format only, not whether the code is registered.
When it is written
The same bytes32 must appear in:
Direct
requestDeposit/requestRedeemEIP-712
RequestDeposit/RequestRedeemand the matchingrequestDepositOnBehalf/requestRedeemOnBehalfcall
Changing the code after signing invalidates the signature. Rebuild and re-sign. To submit requestDepositOnBehalf / requestRedeemOnBehalf without the user paying gas, use the Transaction Relayer.
Encode a referral code
Only a string that is exactly 0x plus 64 hex characters is a ready bytes32. Any other value is a text code: UTF-8, right-padded to 32 bytes. Longer than 32 UTF-8 bytes is invalid. An empty value is bytes32(0).
Install viem and save as referral.mjs.
import { stringToHex, zeroHash } from "viem";
const code = process.env.REFERRAL_CODE ?? "";
let referral;
if (/^0x[0-9a-fA-F]{64}$/.test(code)) {
referral = code;
} else if (code.startsWith("0x")) {
throw new Error("Hex referral must be 0x plus exactly 64 hex characters");
} else if (new TextEncoder().encode(code).length > 32) {
throw new Error("Referral code exceeds 32 UTF-8 bytes");
} else {
referral = code ? stringToHex(code, { size: 32 }) : zeroHash;
}
console.log(referral);The first two commands produce the same bytes32. Pass this value into the vault call and, for a signed request, into the EIP-712 message before signing.
Submit and settle with Vault Lifecycle. Direct and signed how-tos live there; this page does not broadcast a transaction.
Vault LifecycleLast updated