Skip to content

Commit

Permalink
Mintless boc generator
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksej-paschenko committed Aug 20, 2024
1 parent 9a10f79 commit 3c451b6
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ if (NOT CMAKE_CROSSCOMPILING)
endif()
#END tonlib

add_executable(mintless mintless/generator.cpp)
target_link_libraries(mintless tdutils tddb_utils ton_crypto_core ton_block ton_crypto smc-envelope ssl crypto)

#BEGIN internal
if (NOT TON_ONLY_TONLIB)
add_executable(test-db test/test-td-main.cpp ${TONDB_TEST_SOURCE})
Expand Down
74 changes: 74 additions & 0 deletions mintless/generator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

#include "keys/encryptor.h"


#include <memory>
#include <thread>

#include "vm/cells.h"
#include "vm/cellslice.h"
#include "vm/vm.h"
#include "vm/cp0.h"
#include "vm/dict.h"
#include "vm/boc.h"

#include "vm/box.hpp"
#include "vm/atom.h"

#include "smc-envelope/WalletV4.h"

#include <iostream>
#include <fstream>

int main() {

vm::Dictionary dict{267};

long amount = 1;
for (auto i=0;i<20000;i++) {
auto priv_key = td::Ed25519::generate_private_key().move_as_ok();
auto pub_key = priv_key.get_public_key().move_as_ok();
ton::WalletV4::InitData init_data;
init_data.public_key = pub_key.as_octet_string();
init_data.wallet_id = 239;

auto wallet = ton::WalletV4::create(init_data, 2);
auto address = wallet->get_address();

vm::CellBuilder my_addr;
my_addr.store_long_bool(2, 2);
my_addr.store_long(0, 9) ;
my_addr.store_bits_bool(address.addr.cbits(), 256);
auto addr_bits = my_addr.as_cellslice().as_bitslice().bits();

vm::CellBuilder cb;
block::tlb::VarInteger grams(16);

if (amount > 10000) {
amount = 1;
}

auto value = td::make_bigint(amount*1000);
grams.store_integer_value(cb, value);
cb.store_long(1723189734, 48);
cb.store_long(2070247734, 48);
auto ok = dict.set(addr_bits, 267, cb.as_cellslice_ref(), vm::Dictionary::SetMode::Add);
if (!ok) {
std::cout << "not ok";
return 0;
}
amount += 1;
};

auto root = dict.get_root_cell();
auto result = vm::std_boc_serialize(root).move_as_ok();

std::ofstream myfile;
myfile.open ("accounts.boc");
myfile << td::buffer_to_hex(result.as_slice()) ;
myfile.close();

std::cout << "done" << std::endl;

return 0;
}

0 comments on commit 3c451b6

Please sign in to comment.