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

wallet v5r1 create_external_message send boc error #6

Open
alexlee85 opened this issue Aug 30, 2024 · 1 comment
Open

wallet v5r1 create_external_message send boc error #6

alexlee85 opened this issue Aug 30, 2024 · 1 comment

Comments

@alexlee85
Copy link

alexlee85 commented Aug 30, 2024

I use V5R1 Wallet to send some TON, but when I use toncenter api to send base64 encoded boc, it failed.
code

    let keypair = mnemonic.generate_keypair(None)?;
    let wallet = Wallet::<V5R1>::derive(0, keypair, V5R1_MAINNET_WALLET_ID)?;

    let transfer_val = 30_000_000.to_biguint().unwrap();
    let msg = Message::transfer(wallet2.address(), transfer_val, false).normalize()?;
    let action = SendMsgAction {
        mode: 3,
        message: msg,
    };
    let external_msg = wallet.create_external_message(Default::default(), 8, [action], false)?;

    let boc = BagOfCells::from_root(external_msg.to_cell()?);
    println!("boc: {boc:?}");
    let packed = pack_with(
        boc,
        BagOfCellsArgs {
            has_idx: false,
            has_crc32c: true,
        },
    )?;

    let bytes = packed.as_raw_slice();

    let boc_bs64 = base64::engine::general_purpose::STANDARD.encode(bytes);
    println!("base64: {boc_bs64}");

anything I'm wrong? need help !

@mitinarseny
Copy link
Owner

mitinarseny commented Sep 17, 2024

Hi, @alexlee85!
Thank you for your feedback!

TonCenter and other TON APIs usually just ignore the messages that fail at the stage of simulation, as it makes no sense to actually propagate this message further to the validators as it would likely fail there as well.

It seems like there can be either two reasons for it:

  1. You generate the keypair right before sending the transaction. So, there is no code deployed on this address. Therefore, you should pass state_init = true on wallet.create_external_message(...)
  2. The address of the wallet contract that is about to be deployed would also have zero TON balance, so it would fail to pay the state_init fees. You have to deposit some TON to this address first by sending non-bouncible transfer to this address. This type of transfer is usually done by wallet applications like Tonkeeper.

There can also be something wrong with impl WalletVersion for V5R1, but I would start with fixing these two mentioned above first.

If the problem still occurs, please let me know and I'll investigate further!

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

3 participants
@alexlee85 @mitinarseny and others