Skip to content

Fix Python Solana transfer examples: imports, f-strings, and network …#625

Open
stackoverflowed1 wants to merge 1 commit intocoinbase:mainfrom
stackoverflowed1:stackoverflowed1-patch-2
Open

Fix Python Solana transfer examples: imports, f-strings, and network …#625
stackoverflowed1 wants to merge 1 commit intocoinbase:mainfrom
stackoverflowed1:stackoverflowed1-patch-2

Conversation

@stackoverflowed1
Copy link
Copy Markdown

Description

This PR fixes several issues in the Python Solana transfer examples to make them self-contained and functional:

Added missing import:

LAMPORTS_PER_SOL is now imported from solana.rpc.types to correctly compute SOL amounts.

Fixed transaction confirmation printing:

Removed JavaScript-style .toString() from confirmation.value.err.

Fixed f-string in explorer URL: replaced https://explorer.solana.com/tx/${signature}?cluster=devnet with the correct Python f-string https://explorer.solana.com/tx/{signature}?cluster=devnet.

Corrected network specification:

The USDC transfer example currently specifies “network=devet”, which is a typo. I have corrected it to “network=devnet”

Fixed confirm_transaction argument formatting:

Replaced the JS-style positional dict with a proper Python dictionary:

{
    "signature": signature,
    "blockhash": blockhash,
    "lastValidBlockHeight": lastValidBlockHeight,
}

This ensures Python interprets the transaction confirmation parameters correctly, avoiding any runtime errors.

Checklist

A couple of things to include in your PR for completeness:

  • Updated the typescript README if relevant
  • Updated the python README if relevant
  • Added a changelog entry
  • Added e2e tests if introducing new functionality

…typo

This PR fixes several issues in the Python Solana transfer examples to make them self-contained and functional:

Added missing import:

LAMPORTS_PER_SOL is now imported from solana.rpc.types to correctly compute SOL amounts.

Fixed transaction confirmation printing:

Removed JavaScript-style .toString() from confirmation.value.err.

Fixed f-string in explorer URL: replaced https://explorer.solana.com/tx/${signature}?cluster=devnet with the correct Python f-string https://explorer.solana.com/tx/{signature}?cluster=devnet.

Corrected network specification:

In the SOL transfer example, network=connection is used to pass the actual SolanaClient instance.

In the USDC transfer example, network="devnet" is specified, fixing the previous typo "devet". This ensures the SDK resolves the correct Devnet RPC endpoint.

These changes ensure that both examples are functional, Pythonic, and match the intended usage of the SDK.
@cb-heimdall
Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants