最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Buy Operation for Jettons Results in Normal TON Transfer Instead of Token Purchase - Stack Overflow

programmeradmin2浏览0评论

I'm working on a script to purchase Blum tokens using the TEP-74 Jettons standard, but instead of triggering the buy operation, the transaction is being processed as a normal TON transfer. Below is the relevant excerpt from my code:


# Constants - Operation codes from TEP-74
BUY_OP = 0xaf750d34  # Convert from string as defined in contract

def create_buy_payload():
    """Creates payload for buying Blum tokens"""
    try:
        # Create the builder for the main message
        body = begin_cell()
        body.store_uint(BUY_OP, 32)        # buy operation
        body.store_uint(0, 64)             # query id
        body.store_coins(0)                # min_receive_amount
        body.store_uint(0, 1)              # no referral
        # Additional fields required by the contract may be added here
        return body.end_cell()
    except Exception as e:
        print(f"❌ Error creating payload: {str(e)}")
        raise

async def buy_blum():
    """Purchases Blum tokens"""
    client = await get_client()
    wallet = import_wallet(my_mnemonics)

    # Get wallet address and sequence number
    wallet_address = wallet.address.to_string()
    state = await client.generic_get_account_state(wallet_address)
    seqno = state.get('account_state', {}).get('seqno', 0)
    
    # Create the buy payload
    payload = create_buy_payload()
    
    # Create the transfer message with the payload attached
    query = wallet.create_transfer_message(
        to_addr=JETTON_MASTER,
        amount=to_nano(AMOUNT + MIN_GAS, 'ton'),
        seqno=seqno,
        payload=payload,
        send_mode=3
    )
    
    message_boc = query['message'].to_boc(False)
    await client.raw_send_message(message_boc)

Despite using the BUY_OP and constructing the payload accordingly, the operation doesn’t trigger token purchase logic on the contract side—it only executes as a regular TON transfer.

Questions:

Is the payload format incomplete or missing additional fields required by the TEP-74 specification for buying jettons?
What additional parameters or data should be included in the payload for the contract to recognize and execute a buy operation?
Any guidance or suggestions would be appreciated. Thank you!

发布评论

评论列表(0)

  1. 暂无评论