-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I failed to get wallet v5 friendly string #354
Comments
Hello @0xBeycan you could see this code as a reference:
|
Thanks, by the way, I would like to ask, you can send a TON from addresses in different versions to each other. So I don't have a problem with versions in the transfer process. But when the user sends the wallet address as a parameter, how can I find out which version that address belongs to? |
@KuznetsovNikita By the way, I already tried WalletContractV5R1 but I don't see the same address I see in my wallet in the toString method. It gives a completely different address. |
The easiest way you may try ‘tonapi’ method ‘getAccount’ - https://tonapi.io/api-v2 it’s work when we know a code of the contract |
It's not possible with TonClient? I am using it now. And my mind is a little bit mixed now. Because other blockchains generally have an RPC endpoint and you can access everything with it. But TON have different API's and providers. Also, do you know how to get transaction data by hash? ton-org/ton#77 |
Also, your main documentation is very complicated, do you know of any simpler documentation that explains how to do the basic things that we can do on other blockchains? |
It’s possible, but required to do a few steps. |
There is no such nonsense, I think he detected me as a bot and banned me. I can't join the group right now. I've looked through the Tonkeeper repos and I can't find an example of what I want. Is there an example you can give me? |
I stole the source code for the following service and actually figured out how to do it, but man, it's slow. I really don't understand how it is not possible to get tx data with hash. All blockchains have this. |
@KuznetsovNikita My friend, how can I create WalletContract from friendlyAddress? When I parse it with address, I actually get the correct value and I can get the balance value with address again. But when I use it for WalletContract, I get a wrong friendlyAddress and balance value. Yes, I can already create the correct WalletContract from keyPair, but what should I do in friendlyAddress? async function createWalletFromFriendlyAddress(friendlyAddressStr: string) {
try {
const {address} = Address.parseFriendly(friendlyAddressStr);
const workchain = 0;
const wallet = WalletContractV5R1.create({
workchain,
walletId: {
networkGlobalId: -239, // TESTNET
},
publicKey: address.hash
});
const client = new TonClient({
endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC',
});
const onlineWallet = client.open(wallet);
const walletAddress = wallet.address.toString({
bounceable: false,
testOnly: true
});
const balance = await onlineWallet.getBalance();
return {
address: walletAddress,
balance: balance.toString(),
address2: address.toString(standard),
};
} catch (error) {
console.error('Wallet creation error:', error);
throw error;
}
}
// create wallet from friendly address
;(async () => {
try {
const result = await createWalletFromFriendlyAddress(
'0QBh14OFHZqXqMyAHUio8EZ9FAf5smnkcmb0j533aHtFNcsF'
);
console.log('wallet:', result);
} catch (error) {
console.error('Error:', error);
}
})() wallet: { |
also I think in TON the tx fee is deducted from both addresses, not from the sending address. How do I avoid this? I tried it in Tonkeeper and my code is as below. I tried all sendModes but I always get 0.09*** even though I send 0.1. async sign(privateKey: PrivateKey): Promise<this> {
const { publicKey, secretKey } = await mnemonicToPrivateKey(privateKey.split(' '))
const contract = this.provider.createWalletV5R1(publicKey)
this.wallet = this.provider.client1.open(contract)
const seqno = await this.wallet.getSeqno()
this.signedData = this.wallet.createTransfer({
seqno,
secretKey,
messages: [this.rawData],
sendMode: SendMode.PAY_GAS_SEPARATELY
})
return this
} |
Also how can I get tx hash? :D await this.provider.client1.sendExternalMessage(this.wallet, this.signedData)
return this.signedData.hash().toString('hex') |
Also, TON doesn't have approval for token spending? I mean adding a delegator. |
Hello, I can get the V4 address in the example below, but I could not get the V5 address. Can you help me with this?
The text was updated successfully, but these errors were encountered: