1

I get the WeightNotComputable error when I try to send this XCM transaction. What am I doing wrong?

In the documentation I've read:

WeightNotComputable
The weight of an XCM message is not computable ahead of execution.

I know the XCM pallet can't know the required weight beforehand...but I don't understand why I get this error ?

PS: To create the XCM transaction call in a script I've done this:

    const destination = {
        X1: {
            Parachain: parachainId.toNumber(),
        }
    };

    let templatePallet_hex_call = await parachainApi.tx.templatePallet.doSomething(22).signAsync(account);
    console.log("templatePallet_hex_call", inspect(templatePallet_hex_call.toHex(), false, null, true))

    const message = {
        Transact: { originType: "Native", requireWeightAtMost: 10000000000, call: compactAddLength(hexToU8a(templatePallet_hex_call.toHex())) }
    }
    
    console.log("destination", inspect(destination, false, null, true))
    console.log("message", inspect(message, false, null, true))

    const txHash = await relaychainApiInst.tx.xcmPallet.send(destination, message).signAndSend(account);

screenshot

2

1 Answer 1

1

Its been a while, but I think I solved it using this code bellow.

Note the .method.toU8a() to get the call.

const destination = {
    V0: {
        X1: {
            Parachain: parachainId.toNumber(),
        }
    }
};

let templatePalletcall = await parachainApiInstInsurance.tx.templatePallet.doXcmMessage(account.address, "Hello world").method.toU8a()


const message = {
    V0: {
        Transact: {
            originType: "Native",
            requireWeightAtMost: 100000,
            call: {
                encoded: compactAddLength(templatePalletcall)
            }
        }
    }
}

const txHash = await relaychainApiInst.tx.xcmPallet.send(destination, message).signAndSend(account);

console.log("txHash: ", txHash.toHex())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.