const payloadToSign = Buffer.concat([Buffer.from([0, 0, 0, 0]), Buffer.from('Some random string')]);
const payload = beginCell()
.storeBuffer(payloadToSign)
.endCell()
.toBoc({idx:false})
.toString('base64');
const text = 'Please, sign our terms or service and privacy policy';
// Request body
const request: TonhubLocalSignRequest = {
text: 'Hello world', // Text to sign, presented to the user.
payload: payload // Optional serialized to base64 string payload cell
};
const response: TonhubLocalSignResponse = await connector.requestSign(request);
if (response.type === 'rejected') {
// Handle rejection
} else if (response.type === 'success') {
// Handle successful transaction
const signature = response.signature;
// You can check signature on the backend with TonhubConnector.verifySignatureResponse
let correctSignature = TonhubConnector.verifySignatureResponse({ signature: signature, config: walletConfig });
} else {
throw new Error('Impossible');
}