PreprocessedV2 is class to work with Preprocessed v2 wallet.
To create PreprocessedV2 instance you can use class constructor:
// create new mnemonic or use existingMnemonic mnemonic =newMnemonic();// create wallet optionsPreprocessedV2Options options =newPreprocessedV2Options(){ PublicKey =mnemonic.Keys.PublicKey, Workchain =0// set workchain if needed};PreprocessedV2 wallet =newPreprocessedV2(options);
You can create deploy message using CreateDeployMessage method:
PreprocessedV2 wallet =newPreprocessedV2(options); // create deploy messageExternalInMessage message =wallet.CreateDeployMessage();// sign deploy messagemessage.Sign(mnemonic.Keys.PrivateKey,true);// get message cellCell cell =message.Cell;// send this message via TonClient,// for example, await tonClient.SendBoc(cell);
Also you can create deploy message using CreateTransferMessage method:
Address destination =newAddress("/* destination address */");Coins amount =newCoins(1); // 1 TONstring comment ="Hello TON!";PreprocessedV2 wallet =newPreprocessedV2(options); // create transaction body query + commentCell body =newCellBuilder().StoreUInt(0,32).StoreString(comment).Build();// getting seqno using tonClientuint? seqno =awaittonClient.Wallet.GetSeqno(wallet.Address);// create transfer messageExternalInMessage message =wallet.CreateTransferMessage(new[]{newWalletTransfer { Message =newInternalMessage(newInternalMessageOptions { Info =newIntMsgInfo(newIntMsgInfoOptions { Dest = destination, Value = amount, }), Body = body }), Mode =1// message mode }}, seqno ??0); // if seqno is null we pass 0, wallet will auto deploy on message send// sign transfer messagemessage.Sign(mnemonic.Keys.PrivateKey,true);// get message cellCell cell =message.Cell;// send this message via TonClient,// for example, await tonClient.SendBoc(cell);
To get more info about message modes check this page.
If you will pass seqno = 0, message will contain state init data.