You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import TonWeb from 'tonweb';
async function createAndDeployWallet() {
// Step 1: Initialize TonWeb provider
const tonweb = new TonWeb(new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', { apiKey: '' }));
// Step 2: Generate a new key pair (secretKey and publicKey)
const keyPair = TonWeb.utils.newKeyPair();
const publicKey = keyPair.publicKey;
const secretKey = keyPair.secretKey;
console.log('Public Key:', TonWeb.utils.bytesToHex(publicKey));
console.log('Secret Key:', TonWeb.utils.bytesToHex(secretKey));
// Step 3: Create a new wallet instance using the public key
const wallet = tonweb.wallet.create({ publicKey });
// Step 4: Get the wallet address (asynchronous)
const address = await wallet.getAddress();
const nonBounceableAddress = address.toString(true, true, false);
console.log('Wallet Address (non-bounceable):', nonBounceableAddress);
const accountState = await tonweb.provider.getAddressInfo(nonBounceableAddress);
console.log('Account State:', accountState);
// Step 5: Get the current seqno (sequence number) of the wallet
const seqno = await wallet.methods.seqno().call();
console.log('Seqno:', seqno);
// Step 6: Deploy the wallet contract to the blockchain (asynchronous)
try {
await wallet.deploy(secretKey).send();
console.log("Wallet deployed successfully!");
} catch (error) {
console.error("Error during wallet deployment:", error);
return; // Stop further execution if deployment fails
}
}
// Run the asynchronous function
await createAndDeployWallet();
I get error when i want to deploy the wallet to the blockchain only when i specify apiKey which was obtained from @tonapibot tg bot:
LITE_SERVER_UNKNOWN: cannot apply external message to current state : Failed to unpack account state
without apiKey, code works fine, whats its problem?
The text was updated successfully, but these errors were encountered:
m0x61h0x64i
changed the title
Basic Error: LITE_SERVER_UNKNOWN: cannot apply external message to current state : Failed to unpack account state
-
Oct 11, 2024
m0x61h0x64i
changed the title
-
Basic Error: LITE_SERVER_UNKNOWN: cannot apply external message to current state : Failed to unpack account state
Oct 11, 2024
this is my code:
I get error when i want to deploy the wallet to the blockchain only when i specify apiKey which was obtained from @tonapibot tg bot:
without apiKey, code works fine, whats its problem?
The text was updated successfully, but these errors were encountered: