Create a Transfer Request

Create a Solana Pay transfer transaction request.

def create_transfer(client: Client, sender: Keypair, transfer_fields: CreateTransferFields, commitment: Optional[Commitment] = None)
copy

Parameters

client: Client

A connection client to the cluster.

sender: Keypair

Account that will send the transfer.

transfer_fields: CreateTransferFields

Fields of a Solana Pay transfer request URL.

commitment (Commitment, optional)

Commitment option for get_recent_blockhash.

Returns valid Transaction request with given parameters

Example

from solathon.solana_pay import create_transfer
from solathon import Client, Keypair, PublicKey
client = Client("https://api.devnet.solana.com")
customer = Keypair()
recipient = PublicKey("mvines9iiHiQTysrwkJjGf2gb9Ex9jXJX8ns3qwf2kN")
reference = Keypair().public_key
# Alternatively can pass list of `public_key` as reference, like so
# reference = [Keypair().public_key, Keypair().public_key]
amount = 0.01
transfer: Transaction = create_transfer(client, customer, {
"recipient": recipient, "amount": amount, "reference": reference})
copy

The complete example code can be found here.