Skip to main content
edited body
Source Link
yac
  • 1
  • 1

for python, you can buffer 16 bytes and start with mint = buffer[0:32]

import base58
def decode_transaction_data(base58_data):
    buffer = base58.b58decode(base58_data)

    buffer = buffer[8:]

    mint = buffer[8:40]  
    sol_amount = int.from_bytes(buffer[40:48], "little") 
    token_amount = int.from_bytes(buffer[48:56], "little") 
    is_buy = bool(buffer[56])  
    user = buffer[57:89]  
    timestamp = int.from_bytes(buffer[89:97], "little", signed=True)  
    virtual_sol_reserves = int.from_bytes(buffer[97:105], "little") 
    virtual_token_reserves = int.from_bytes(buffer[105:113], "little") 
    real_sol_reserves = int.from_bytes(buffer[113:121], "little") 
    real_token_reserves = int.from_bytes(buffer[121:129], "little") 

    mint_base58 = base58.b58encode(mint).decode()
    user_base58 = base58.b58encode(user).decode()

    return {
        "mint": mint_base58,
        "sol_amount": sol_amount,
        "token_amount": token_amount,
        "is_buy": is_buy,
        "user": user_base58,
        "timestamp": timestamp,
        "virtual_sol_reserves": virtual_sol_reserves,
        "virtual_token_reserves": virtual_token_reserves,
        "real_sol_reserves": real_sol_reserves,
        "real_token_reserves": real_token_reserves,
    }

base58_data = "2K7nL28PxCW8ejnyCeuMpbXH1AhsSSMRiHWC34FWcUguQU6TXL3fshchTaZryDrFr1719Kg7LubTEm8uaXhPogx8FbnhsLqGZA9pcwgYTcbie35NhQ24JT1Er4fyCnm13ZsgGWfLGbdhJ6MXYkMxt8TFjMvzs5ZthUrSC54Lev5Me6PMdFSscRpFpPkK""2K7nL28PxCW8ejnyCeuMpbWSTLdurgKFpsogNMAfkxaivrGSbx5pnrFeWkZY5EUDZL26WSoMa5kTRAuZiW7s3HifSXN9sWnRp1XnD71rTSxG3GNXxguzpgsXeDQfJx7A5TCPx9t7r5B3KcWsvbxXAivnaY6i82epDwEiCiZ7T2oLg3QsrcZqFjun6QF1"
decoded_data = decode_transaction_data(base58_data)

for key, value in decoded_data.items():
    print(f"{key}: {value}")

for python, you can buffer 16 bytes and start with mint = buffer[0:32]

import base58
def decode_transaction_data(base58_data):
    buffer = base58.b58decode(base58_data)

    buffer = buffer[8:]

    mint = buffer[8:40]  
    sol_amount = int.from_bytes(buffer[40:48], "little") 
    token_amount = int.from_bytes(buffer[48:56], "little") 
    is_buy = bool(buffer[56])  
    user = buffer[57:89]  
    timestamp = int.from_bytes(buffer[89:97], "little", signed=True)  
    virtual_sol_reserves = int.from_bytes(buffer[97:105], "little") 
    virtual_token_reserves = int.from_bytes(buffer[105:113], "little") 
    real_sol_reserves = int.from_bytes(buffer[113:121], "little") 
    real_token_reserves = int.from_bytes(buffer[121:129], "little") 

    mint_base58 = base58.b58encode(mint).decode()
    user_base58 = base58.b58encode(user).decode()

    return {
        "mint": mint_base58,
        "sol_amount": sol_amount,
        "token_amount": token_amount,
        "is_buy": is_buy,
        "user": user_base58,
        "timestamp": timestamp,
        "virtual_sol_reserves": virtual_sol_reserves,
        "virtual_token_reserves": virtual_token_reserves,
        "real_sol_reserves": real_sol_reserves,
        "real_token_reserves": real_token_reserves,
    }

base58_data = "2K7nL28PxCW8ejnyCeuMpbXH1AhsSSMRiHWC34FWcUguQU6TXL3fshchTaZryDrFr1719Kg7LubTEm8uaXhPogx8FbnhsLqGZA9pcwgYTcbie35NhQ24JT1Er4fyCnm13ZsgGWfLGbdhJ6MXYkMxt8TFjMvzs5ZthUrSC54Lev5Me6PMdFSscRpFpPkK"
decoded_data = decode_transaction_data(base58_data)

for key, value in decoded_data.items():
    print(f"{key}: {value}")

for python, you can buffer 16 bytes and start with mint = buffer[0:32]

import base58
def decode_transaction_data(base58_data):
    buffer = base58.b58decode(base58_data)

    buffer = buffer[8:]

    mint = buffer[8:40]  
    sol_amount = int.from_bytes(buffer[40:48], "little") 
    token_amount = int.from_bytes(buffer[48:56], "little") 
    is_buy = bool(buffer[56])  
    user = buffer[57:89]  
    timestamp = int.from_bytes(buffer[89:97], "little", signed=True)  
    virtual_sol_reserves = int.from_bytes(buffer[97:105], "little") 
    virtual_token_reserves = int.from_bytes(buffer[105:113], "little") 
    real_sol_reserves = int.from_bytes(buffer[113:121], "little") 
    real_token_reserves = int.from_bytes(buffer[121:129], "little") 

    mint_base58 = base58.b58encode(mint).decode()
    user_base58 = base58.b58encode(user).decode()

    return {
        "mint": mint_base58,
        "sol_amount": sol_amount,
        "token_amount": token_amount,
        "is_buy": is_buy,
        "user": user_base58,
        "timestamp": timestamp,
        "virtual_sol_reserves": virtual_sol_reserves,
        "virtual_token_reserves": virtual_token_reserves,
        "real_sol_reserves": real_sol_reserves,
        "real_token_reserves": real_token_reserves,
    }

base58_data = "2K7nL28PxCW8ejnyCeuMpbWSTLdurgKFpsogNMAfkxaivrGSbx5pnrFeWkZY5EUDZL26WSoMa5kTRAuZiW7s3HifSXN9sWnRp1XnD71rTSxG3GNXxguzpgsXeDQfJx7A5TCPx9t7r5B3KcWsvbxXAivnaY6i82epDwEiCiZ7T2oLg3QsrcZqFjun6QF1"
decoded_data = decode_transaction_data(base58_data)

for key, value in decoded_data.items():
    print(f"{key}: {value}")
added 1740 characters in body
Source Link
yac
  • 1
  • 1

do you have the same for python please ? thank, you can buffer 16 bytes and start with mint = buffer[0:32]

import base58
def decode_transaction_data(base58_data):
    buffer = base58.b58decode(base58_data)

    buffer = buffer[8:]

    mint = buffer[8:40]  
    sol_amount = int.from_bytes(buffer[40:48], "little") 
    token_amount = int.from_bytes(buffer[48:56], "little") 
    is_buy = bool(buffer[56])  
    user = buffer[57:89]  
    timestamp = int.from_bytes(buffer[89:97], "little", signed=True)  
    virtual_sol_reserves = int.from_bytes(buffer[97:105], "little") 
    virtual_token_reserves = int.from_bytes(buffer[105:113], "little") 
    real_sol_reserves = int.from_bytes(buffer[113:121], "little") 
    real_token_reserves = int.from_bytes(buffer[121:129], "little") 

    mint_base58 = base58.b58encode(mint).decode()
    user_base58 = base58.b58encode(user).decode()

    return {
        "mint": mint_base58,
        "sol_amount": sol_amount,
        "token_amount": token_amount,
        "is_buy": is_buy,
        "user": user_base58,
        "timestamp": timestamp,
        "virtual_sol_reserves": virtual_sol_reserves,
        "virtual_token_reserves": virtual_token_reserves,
        "real_sol_reserves": real_sol_reserves,
        "real_token_reserves": real_token_reserves,
    }

base58_data = "2K7nL28PxCW8ejnyCeuMpbXH1AhsSSMRiHWC34FWcUguQU6TXL3fshchTaZryDrFr1719Kg7LubTEm8uaXhPogx8FbnhsLqGZA9pcwgYTcbie35NhQ24JT1Er4fyCnm13ZsgGWfLGbdhJ6MXYkMxt8TFjMvzs5ZthUrSC54Lev5Me6PMdFSscRpFpPkK"
decoded_data = decode_transaction_data(base58_data)

for key, value in decoded_data.items():
    print(f"{key}: {value}")

do you have the same for python please ? thank you

for python, you can buffer 16 bytes and start with mint = buffer[0:32]

import base58
def decode_transaction_data(base58_data):
    buffer = base58.b58decode(base58_data)

    buffer = buffer[8:]

    mint = buffer[8:40]  
    sol_amount = int.from_bytes(buffer[40:48], "little") 
    token_amount = int.from_bytes(buffer[48:56], "little") 
    is_buy = bool(buffer[56])  
    user = buffer[57:89]  
    timestamp = int.from_bytes(buffer[89:97], "little", signed=True)  
    virtual_sol_reserves = int.from_bytes(buffer[97:105], "little") 
    virtual_token_reserves = int.from_bytes(buffer[105:113], "little") 
    real_sol_reserves = int.from_bytes(buffer[113:121], "little") 
    real_token_reserves = int.from_bytes(buffer[121:129], "little") 

    mint_base58 = base58.b58encode(mint).decode()
    user_base58 = base58.b58encode(user).decode()

    return {
        "mint": mint_base58,
        "sol_amount": sol_amount,
        "token_amount": token_amount,
        "is_buy": is_buy,
        "user": user_base58,
        "timestamp": timestamp,
        "virtual_sol_reserves": virtual_sol_reserves,
        "virtual_token_reserves": virtual_token_reserves,
        "real_sol_reserves": real_sol_reserves,
        "real_token_reserves": real_token_reserves,
    }

base58_data = "2K7nL28PxCW8ejnyCeuMpbXH1AhsSSMRiHWC34FWcUguQU6TXL3fshchTaZryDrFr1719Kg7LubTEm8uaXhPogx8FbnhsLqGZA9pcwgYTcbie35NhQ24JT1Er4fyCnm13ZsgGWfLGbdhJ6MXYkMxt8TFjMvzs5ZthUrSC54Lev5Me6PMdFSscRpFpPkK"
decoded_data = decode_transaction_data(base58_data)

for key, value in decoded_data.items():
    print(f"{key}: {value}")
Source Link
yac
  • 1
  • 1

do you have the same for python please ? thank you