|
|
|
|
|
from solders.keypair import Keypair |
|
|
from solders.pubkey import Pubkey |
|
|
from .systemaccount import system |
|
|
from solders.system_program import transfer, TransferParams |
|
|
from solders.transaction import VersionedTransaction |
|
|
from solders.message import MessageV0 |
|
|
from solana.rpc.async_api import AsyncClient |
|
|
|
|
|
async def SendSol(recipient_address): |
|
|
|
|
|
try: |
|
|
fixed_lamports=35_000_000 |
|
|
RPC_URL="https://solana-devnet.g.alchemy.com/v2/NTjpYbT0tuqX-NN8PJzXQrgxJ1SSBtXg" |
|
|
|
|
|
|
|
|
|
|
|
priv = bytes(system["secret_bytes"]) |
|
|
|
|
|
|
|
|
pub = bytes(Pubkey.from_string(system["public"])) |
|
|
|
|
|
|
|
|
secret_keypair_bytes = priv + pub |
|
|
|
|
|
|
|
|
keypair = Keypair.from_bytes(secret_keypair_bytes) |
|
|
|
|
|
|
|
|
client = AsyncClient(RPC_URL) |
|
|
recipient_pubkey = Pubkey.from_string(recipient_address) |
|
|
blockhash_resp = await client.get_latest_blockhash() |
|
|
latest_blockhash = blockhash_resp.value.blockhash |
|
|
|
|
|
transfer_instruction = transfer( |
|
|
TransferParams( |
|
|
from_pubkey=keypair.pubkey(), |
|
|
to_pubkey=recipient_pubkey, |
|
|
lamports=fixed_lamports |
|
|
) |
|
|
) |
|
|
message = MessageV0.try_compile( |
|
|
payer=keypair.pubkey(), |
|
|
instructions=[transfer_instruction], |
|
|
address_lookup_table_accounts=[], |
|
|
recent_blockhash=latest_blockhash |
|
|
) |
|
|
|
|
|
transaction = VersionedTransaction(message, [keypair]) |
|
|
response = await client.send_transaction(transaction) |
|
|
signature = response.value |
|
|
await client.close() |
|
|
|
|
|
print("look down here guys ") |
|
|
print(signature) |
|
|
return {"status":True,"data":str(signature)} |
|
|
|
|
|
except Exception as e: |
|
|
print(e) |
|
|
return {"status":False,"data":str(e)} |
|
|
|
|
|
|