ton-connect / sdk

SDK for TON Connect 2.0 — a comprehensive communication protocol between wallets and apps in TON ecosystem
Apache License 2.0
165 stars 40 forks source link

the response of tonconnectUI.sendTransaction()? #189

Closed huangxok closed 1 week ago

huangxok commented 2 weeks ago

Your Question

the respose of tonconnectUI.sendTransaction()? I have read the document about tonconnectUI.sendTransaction method. the method return a boc. so what's the boc?

is it a message hash? how to analysis the boc?

`const transaction = { validUntil: Math.floor(Date.now() / 1000) + 60, // 60 sec messages: [ { address: "EQBBJBB3HagsujBqVfqeDUPJ0kXjgTPLWPFFffuNXNiJL0aA", amount: "20000000", // stateInit: "base64bocblahblahblah==" // just for instance. Replace with your transaction initState or remove }, { address: "EQDmnxDMhId6v1Ofg_h5KR5coWlFG6e86Ro3pc7Tq4CA0-Jn", amount: "60000000", // payload: "base64bocblahblahblah==" // just for instance. Replace with your transaction payload or remove } ] }

try { const result = await tonConnectUI.sendTransaction(transaction);

// you can use signed boc to find the transaction 
// what‘s myAppExplorerService.getTransaction to do?
const someTxData = await myAppExplorerService.getTransaction(result.boc);
alert('Transaction was sent successfully', someTxData);

} catch (e) { console.error(e); }`

Context

No response

What have you tried so far?

No response

Relevant Code or Commands

No response

Documentation Check

huangxok commented 2 weeks ago

resolution: ` import TonWeb from 'tonweb'

const result = await tonConnectUI.sendTransaction(transaction);

const bocCellBytes = await TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(result.boc)).hash();

const hashBase64 = TonWeb.utils.bytesToBase64(bocCellBytes);

// hashBase64: vgDP5GJPUKL-Cv_wkUnurlgRF4P8brhSf5zhAGUtosM=

// https://tonscan.org/tx/by-msg-hash/vgDP5GJPUKL-Cv_wkUnurlgRF4P8brhSf5zhAGUtosM= `

huangxok commented 2 weeks ago

https://github.com/ton-connect/sdk/issues/189#issuecomment-2176494132 the hasebase64 is in,how to get the out hash?

huangxok commented 1 week ago

anthor way:

` import { Cell } from '@ton/core';

const transactionRes = await walletConnect.sendTransaction() const cell = Cell.fromBase64(transactionRes.boc) const buffer = cell.hash(); const hashHex = buffer.toString('hex'); // hashHex: 57123dffb9029bdaa9187b5d035737eea94a1b8c018e2ab1885f245eb95c6e30 // const hashBase64 = buffer.toString('base64');

` // https://tonapi.io/v2/blockchain/transactions/57123dffb9029bdaa9187b5d035737eea94a1b8c018e2ab1885f245eb95c6e30 //