Hi All,

I am trying to use tonProof to connect with dApp.
The problem at the moment is that I get rejection when I am trying to connect with a very generic error. I believe the problem is walletStateInit that I am building. is the below correct way to build the walletStateInit

const stateInit = beginCell().storeUint(6,5) .storeRef(Cell.fromBoc(Buffer.from({data}, 'base64'))[0])
.storeRef(Cell.fromBoc(Buffer.from({code}, 'base64'))[0]) .endCell();
stateInit.toBoc().toString('base64url')

Thank you in advance

Aug 21, 2023, 8:52 AM
You've swapped code with data.
Aug 21, 2023, 9:04 AM
Also the code and data are taken from the api request
https://testnet.toncenter.com/api/v2/getAddressInformation?address=${address}

some wallets do not contain the data and code. reason is because they are unitialised. however they can connect using myTonWallet. how is this possible to generate walletStateInit without having an initialised wallet. For instance this one EQA6tBubkCHHrJxIEs1eNX_qa_iaeMctWH2dJc_m4RSJqq-T
Aug 21, 2023, 9:55 AM
Wallet application has code and data so it can calculate StateInit and wallet address even without initializing it in blockchain.
If you're not given public key, you are unable to verify ton proof.
Aug 21, 2023, 12:22 PM
I have given public key correctly. I still think the walletStateInit passing is not correct. as mentioned above I have tried generating the walletStateInit using a walletContractV4.

const stateInit = beginCell().storeUint(6,5)
.storeRef(Cell.fromBoc(Buffer.from({code}, 'base64'))[0])
.storeRef(Cell.fromBoc(Buffer.from({data}, 'base64'))[0])
.endCell();
stateInit.toBoc().toString('base64url')

Still getting unexpected error and I am not sure how I could find what is actually wrong with the request. any way to debug or check what could be wrong?
Aug 21, 2023, 12:25 PM
Buffer.from(data, 'base64') instead of Buffer.from({data}, 'base64')?
Also, what do you do with StateInit afterwards?
Aug 21, 2023, 12:26 PM
yeah I used {data} as placeholder I get the data from this api
https://testnet.toncenter.com/api/v2/getAddressInformation?address=${address}
Just passing it into the dApp for validation. including public key, signature, something like below:

{
"id": 1,
"event": "connect",
"payload": {
"items": [
{
"name": "ton_addr",
"address": "0:c098da2b868f6eb5bf2db066c05398b6147d1bbdd0cf7f6a8f2280e557f832f0",
"network": "-3",
"walletStateInit": "te6ccgECFAEAAtQAART/APSkE/S88sgLAQIBIAIDAgFIBAUE+PKDCNcYINMf0x/THwL4I7vyZO1E0NMf0x/T//QE0VFDuvKhUVG68qIF+QFUEGT5EPKj+AAkpMjLH1JAyx9SMMv/UhD0AMntVPgPAdMHIcAAn2xRkyDXSpbTB9QC+wDoMOAhwAHjACHAAuMAAcADkTDjDQOkyMsfEssfy/8QERITAubQAdDTAyFxsJJfBOAi10nBIJJfBOAC0x8hghBwbHVnvSKCEGRzdHK9sJJfBeAD+kAwIPpEAcjKB8v/ydDtRNCBAUDXIfQEMFyBAQj0Cm+hMbOSXwfgBdM/yCWCEHBsdWe6kjgw4w0DghBkc3RyupJfBuMNBgcCASAICQB4AfoA9AQw+CdvIjBQCqEhvvLgUIIQcGx1Z4MesXCAGFAEywUmzxZY+gIZ9ADLaRfLH1Jgyz8gyYBA+wAGAIpQBIEBCPRZMO1E0IEBQNcgyAHPFvQAye1UAXKwjiOCEGRzdHKDHrFwgBhQBcsFUAPPFiP6AhPLassfyz/JgED7AJJfA+ICASAKCwBZvSQrb2omhAgKBrkPoCGEcNQICEekk30pkQzmkD6f+YN4EoAbeBAUiYcVnzGEAgFYDA0AEbjJftRNDXCx+AA9sp37UTQgQFA1yH0BDACyMoHy//J0AGBAQj0Cm+hMYAIBIA4PABmtznaiaEAga5Drhf/AABmvHfaiaEAQa5DrhY/AAG7SB/oA1NQi+QAFyMoHFcv/ydB3dIAYyMsFywIizxZQBfoCFMtrEszMyXP7AMhAFIEBCPRR8qcCAHCBAQjXGPoA0z/IVCBHgQEI9FHyp4IQbm90ZXB0gBjIywXLAlAGzxZQBPoCFMtqEssfyz/Jc/sAAgBsgQEI1xj6ANM/MFIkgQEI9Fnyp4IQZHN0cnB0gBjIywXLAlAFzxZQA/oCE8tqyx8Syz/Jc/sAAAr0AMntVA=="
},
{
"name": "ton_proof",
"proof": {
"timestamp": 1692361654,
"domain": {
"lengthBytes": 18,
"value": "testnet.getgems.io"
},
"signature": "signature",
"payload": "gems"
}
}
],
"device": {
"platform": "mac",
"appName": "AA",
"appVersion": "1.0",
"maxProtocolVersion": 2,
"features": [
"SendTransaction",
{
"name": "SendTransaction",
"maxMessages": 4
}
]
}
}
}
Aug 21, 2023, 12:27 PM
network: -3 is test-net btw
Aug 21, 2023, 11:54 PM
yes, I am trying to connect with a dApp in testnet
Aug 21, 2023, 11:54 PM

© 2024 Draquery.com All rights reserved.