Hinkal Mobile SDK

Transfers

A private transfer sends tokens from your private balance to another Hinkal user's private balance (private → private). There is no public trace of sender, recipient, or amount. It runs server-side through a Hinkal relayer.

Basic Transfer

SDK calls take an NSError out-parameter, wrapped here with the call helper from Getting Started.

let wei = try call { MobileAmountToWei(chainId, tokenAddress, "0.5", &$0) }
let txHash = try call {
    hinkal.transfer(
        chainId,
        tokenAddrsJSON: "[\"\(tokenAddress)\"]",
        amountsWeiJSON: "[\"\(wei)\"]",
        recipient: recipientPrivateAddress,
        feeToken: tokenAddress,
        feeStructureJSON: "",
        error: &$0
    )
}
print("Transfer tx:", txHash)

Parameters

ParameterTypeDescription
chainIDInt64Target chain id.
tokenAddrsJSONStringJSON array of token addresses.
amountsWeiJSONStringJSON array of amounts in wei.
recipientStringThe recipient's Hinkal private address.
feeTokenStringToken the relayer fee is paid in.
feeStructureJSONStringFee quote, or empty for defaults.

Recipient addresses

The recipient is a Hinkal private address. The recipient shares theirs via getRecipientInfo, and you can validate a value with MobileIsValidPrivateAddress(_:):

guard MobileIsValidPrivateAddress(recipientPrivateAddress) else {
    // prompt the user to re-enter the address
    return
}

Error Handling

do {
    let txHash = try call {
        hinkal.transfer(chainId, tokenAddrsJSON: "[\"\(tokenAddress)\"]", amountsWeiJSON: "[\"\(wei)\"]",
                        recipient: recipientPrivateAddress, feeToken: tokenAddress, feeStructureJSON: "", error: &$0)
    }
} catch {
    print("Transfer failed:", error.localizedDescription)
}

Best Practices

1. Validate the recipient

guard MobileIsValidPrivateAddress(recipient) else { return }

2. Confirm the balance covers amount + fee

The fee is charged on top of the amount; ensure the shielded balance covers amount + fee (quote with the fee helpers on MobileClient).