Skip to content
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

Basic Error: LITE_SERVER_UNKNOWN: cannot apply external message to current state : Failed to unpack account state #278

Open
m0x61h0x64i opened this issue Oct 11, 2024 · 0 comments

Comments

@m0x61h0x64i
Copy link

m0x61h0x64i commented Oct 11, 2024

this is my code:

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?

@m0x61h0x64i 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 m0x61h0x64i changed the title - Basic Error: LITE_SERVER_UNKNOWN: cannot apply external message to current state : Failed to unpack account state Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant