tact-lang / tact-docs

Tact main documentation
https://docs.tact-lang.org
57 stars 39 forks source link

TON Contract Deployment Issue: Invalid Incoming Message #381

Closed bynullname closed 2 months ago

bynullname commented 2 months ago

I'm trying to deploy a smart contract on the TON blockchain using a browser-based interface. I'm referencing the Tact documentation on deployment, but adapting it for in-browser deployment instead of using a deploy link.

Here's the relevant part of my deployment function:

const deployContract = async (params: DeployParams) => {
    let init = await FlyContract.init(
        params.owner,
        params.balance
    );
    let contractAddr = contractAddress(0, init);
    const result = await tonConnectUIRef.value.sendTransaction({
        messages: [
            {
                address: contractAddr.toString(),
                amount: toNano("0.2").toString(),
                stateInit: beginCell().store(storeStateInit(init)).endCell().toBoc().toString('base64')
            }
        ],
        validUntil: Date.now() + 10 * 60 * 1000, // 10 minutes from now
    })
}

The deployment is failing with the following error: 130 Tact (Compiler) Invalid incoming message — no suitable operation is found

I've verified that both init and contractAddr are correct by comparing the contract address generated in my code with the one produced in the Nujan IDE for the same contract. The addresses match exactly, which gives me confidence that these parameters are indeed correct. Despite this verification, the deployment still fails. Furthermore, I can successfully deploy the contract using Nujan IDE without any issues.

bynullname commented 2 months ago

I'm following the method described in the tutorial from the provided link. Specifically, I'm using the TypeScript code generated during compilation: import {FlyContract} from './output/FlyContract'

novusnota commented 2 months ago

Thanks for reporting the issue — that part of the docs ("Getting started" guide) should actually be deprecated as it suggests doing things "barebones" way and not utilizing the power of Blueprint. Not that it's bad to work from scratch (it can certainly teach a lot), but the initial "getting started" should be as streamlined as possible, imo.

That's why I suggest taking a look at the first page of the docs — https://docs.tact-lang.org/#start. It gives all the necessary guidance to get up and running in no time, and then advices on what to do next and where to look for further info.

novusnota commented 2 months ago

Now, regarding your actual question — exit code 130 means that your contract doesn't have an internal message receiver for the message you're trying to send to it. Consider adding an empty receiver like the following:

receive() {}