Validate a Transfer
Check that a given transaction contains a valid Solana Pay transfer.
def validate_transfer(client: Client, signature: str, transfer_fields: CreateTransferFields, commitment: Optional[Commitment] = None)
Parameters
client: Client
A connection client to the cluster.
signature: str
The signature of the transaction to validate.
transfer_fields: CreateTransferFields
Fields of a Solana Pay transfer request URL.
commitment (Commitment, optional)
Commitment option for get_recent_blockhash
.
Returns TransactionElement
Example
from solathon.solana_pay import validate_transfer, find_reference
# Some valid transfer reference obtained before calling `create_transfer`reference = "XYZ"
sign: TransactionSignature = find_reference(client, reference)
# If the function runs succesfully, transfer is validated, else it throws `Exceptions`validate_transfer(client, sign.signature, { "recipient": MERCHENT_WALLET, "amount": amount, "reference": [reference] })print("Transfer Validated")
The complete example code can be found here.