Skip to content

Rust node accepts flags value in McStateExtra rejected by C++ #56

Description

@EmelyanenkoK

C++ has strict condition that flags <=1 https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L577
It is not enforced in Rust implementation: in particular there could be McStateExtra with flag 0x8 that would be treated as presence validators_stat (probably heritage of Eversacle) and, given stats are valid, will be accepted by rust validators / rejected by C++ ones.

Activity

  1. zzcoker38-web commented on Apr 11, 2026

    @zzcoker38-web

    import {
    Address,
    Cell,
    beginCell,
    contractAddress,
    StateInit,
    } from "@ton/core";

    // let's choose Tether USDT as an example

    const jettonwalletcode = Cell.fromHex(
    "b5ee9c72010101010023000842028f452d7a4dfd74066b682365177259ed05734435be76b5fd4bd5d8af2b7c3d68",
    );

    const masterAddress = Address.parse(
    "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe",
    );
    const ownerAddress = Address.parse("an address in any format");
    const jettonwalletdata = beginCell()
    .storeAddress(ownerAddress)
    .storeAddress(masterAddress)
    .storeVarUint(0, 16) // the initial value is always zero
    .endCell();

    const jettonWalletStateInit: StateInit = {
    code: jettonwalletcode,
    data: jettonwalletdata,
    };

    const BASECHAIN = 0; // All Jetton wallet contracts are located in Basechain by default
    const jettonWalletAddress = contractAddress(BASECHAIN, jettonWalletStateInit);

    console.log(jettonWalletAddress.toString());

  2. zzcoker38-web commented on Apr 11, 2026

    @zzcoker38-web

    import {
    Address,
    Cell,
    beginCell,
    contractAddress,
    StateInit,
    } from "@ton/core";

    // let's choose Tether USDT as an example

    const jettonwalletcode = Cell.fromHex(
    "b5ee9c72010101010023000842028f452d7a4dfd74066b682365177259ed05734435be76b5fd4bd5d8af2b7c3d68",
    );

    const masterAddress = Address.parse(
    "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe",
    );
    const ownerAddress = Address.parse("an address in any format");
    const jettonwalletdata = beginCell()
    .storeAddress(ownerAddress)
    .storeAddress(masterAddress)
    .storeVarUint(0, 16) // the initial value is always zero
    .endCell();

    const jettonWalletStateInit: StateInit = {
    code: jettonwalletcode,
    data: jettonwalletdata,
    };

    const BASECHAIN = 0; // All Jetton wallet contracts are located in Basechain by default
    const jettonWalletAddress = contractAddress(BASECHAIN, jettonWalletStateInit);

    console.log(jettonWalletAddress.toString());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions