Encode a url
Encode a Solana Pay URL.
def encode_url(data: TransactionRequestURLParams | TransferRequestURLParams)
Parameters
data: TransactionRequestURLParams | TransferRequestURLParams
Data to encode into a transaction request URL or transfer request URL
Returns encoded url string with data
Example
from solathon.solana_pay import encode_urlfrom solathon import Client, Keypair, PublicKey
label = "Jungle Cats store"message = "Jungle Cats store - your order - #001234"
# Using transfer fieldsclient = Client("https://api.devnet.solana.com")recipient = PublicKey("mvines9iiHiQTysrwkJjGf2gb9Ex9jXJX8ns3qwf2kN")reference = Keypair().public_keyamount = 0.01
url: str = encode_url({"recipient": recipient, "label": label, "message": message, "amount": amount, "reference": reference})
# Using linklink = "https://www.example.com"url: str = encode_url({"link": link, "label": label, "message": message })
The complete example code can be found here.