TON Дев Чат
slice bto_slice(builder b) inline method_id {
return b.end_cell().begin_parse();
}
slice fake_address_1 = begin_cell().store_uint(4, 3).store_uint(10, 8).store_uint(111, 256).end_cell().begin_parse()
"EQAyPDNoPgx7_-DTvAlWo1gGLCsCQR57J-1GFODuUPA8InLC"a
Excno::unknown
поэтому и исключили из доки, может и зря.
_ test_1(int exit_code, cell data, tuple stack, cell actions, int gas) method_id(1)
Если я правильно понимаю, то все сообщения, которые будет отсылать смарт-контракт находяться в ячейке actions
. Но как их можно от туда достать?
op=2
, query_id
and then something else (that means that participants may handle such messages at their discretion
valid_until_dict
.(slice until_slice, int exist) = valid_until_dict~udict_get?(256, key)
udict_get?
: cannot unify type cell with slice(slice, int) udict_get?(cell dict, int key_len, int index
)
It is acceptable to ignore requests which are valid for more than 1 minute
if (valid_until > now() + 60) throw(20);
It is acceptable to ignore requests which are valid for more than 1 minute as well as not accept more than 10 requests per minute.
not accept more than 10 requests per minute.
check_data_signature(cell.begin_parse(), ...)и
check_signature(cell_hash(cell), ...)в том, что второй учитывает ссылки на другие ячейки, а первый считает только хеш от данных?
file.fc
() main() {
int hello = 1;
hello~dump();
}
Через toncli fc build one.fc && toncli f run one.fif
Вывод пустойint main() {
int hello = 1;
hello~impure_touch();
hello~dump();
return hello;
}
toncli fc build one.fc && toncli f run one.fif
2) func -SPA ../func-contest1/stdlib.fc one.fc | FIFTPATH=$TON/lib/fift fift
main
или recv_internal
(они взаимозаменяемы), то fift
крашитсяfunc
прорабатывает нормально, что ожидаемо
one.fif
:"Asm.fif" include
// automatically generated from `../func-contest1/stdlib.fc` `one.fc`
PROGRAM{
DECLPROC main
main PROC:<{
//
1 PUSHINT // hello
s0 DUMP // hello
}>
}END>c
Error interpreting file `one.fif`: one.fif:11: runvmcode:not a cell slice
c
в конце на s
и дописал runvmdict .s
"Asm.fif" includeОсталось понять почему такое не получается сразу при выводе
// automatically generated from `/home/nixi/.config/toncli/func-libs/stdlib.func` `/home/nixi/work/Mini/ton/playground/one.fc`
PROGRAM{
DECLPROC main
main PROC:<{
//
1 PUSHINT // hello
s0 DUMP // hello
}>
}END>s
runvmdict .s
throw_if(78, valid_until > now() + 60);
C:\Users\nns20\Development\TON\contest-1\node_modules\ton-contract-executor\dist\vm-exec\vm-exec.js:147
throw ex;
^
Error: Cant execute vm: invalid bag-of-cells last cell #3: end offset 147 is different from total data size 275
cell pack_data(int public_key1, int public_key2)
liteServer.getMasterchainInfo = liteServer.MasterchainInfo;
var lastBlock: LiteServerMasterchainInfo? = null
while (isActive) {
val currentBlock = liteClient.getMasterchainInfo()
if (currentBlock != lastBlock) {
lastBlock = currentBlock
println("[${Instant.now()}] $currentBlock")
}
delay(1000)
}
$ node main.js
/bin/sh: 1: /home/ruliov/projects/ton/ton-contract-executor-example/node_modules/ton-compiler/bin/macos/func: Exec format error
/home/ruliov/projects/ton/ton-contract-executor-example/node_modules/ton-contract-executor/dist/vm-exec/vm-exec.js:147
throw ex;
^
Error: Command failed: /home/ruliov/projects/ton/ton-contract-executor-example/node_modules/ton-compiler/bin/macos/func -PS -o /tmp/tmp-20936-KPp4q2QVJzRN /home/ruliov/projects/ton/ton-contract-executor-example/node_modules/ton-compiler/funclib/stdlib.fc /tmp/tmp-20936-hHJBbyc3rsIl
at checkExecSyncError (child_process.js:616:11)
at Object.execSync (child_process.js:652:15)
func
tests
js
await testGet();
await testAdd(7);
await testAdd(20);
await testShort(40, 31);
await testAdd(103);
await testAdd(4009);
await testGet();
await testAdd(50003);
await testAdd(600600);
await testGet();
await testAdd(7000004);
await testAdd(80000003);
await testShort(20, 7);
await testAdd(900000002);
await testGet();
await testShort(0, 1);
[int, tuple, cell, tuple, int] test_example_data() method_id(1000) {
return add_message_test(10, 32, 0);
}
_ test_example(int exit_code, cell data, tuple stack, cell actions, int gas) method_id(1001) {
add_message_check(exit_code, data, 10);
}
await testAdd(10);
(int, cell) extract_single_message(cell actions) impure inline method_id {
;; ---------------- Parse actions list
;; prev:^(OutList n)
;; #0ec3c86d
;; mode:(## 8)
;; out_msg:^(MessageRelaxed Any)
;; = OutList (n + 1);
slice cs = actions.begin_parse();
throw_unless(1010, cs.slice_refs() == 2);
cell prev_actions = cs~load_ref();
throw_unless(1011, prev_actions.cell_empty?());
int action_type = cs~load_uint(32);
throw_unless(1013, action_type == 0x0ec3c86d);
int msg_mode = cs~load_uint(8);
throw_unless(1015, msg_mode == 64); ;; !!! check msg_mode
cell msg = cs~load_ref();
throw_unless(1017, cs.slice_empty?());
return (msg_mode, msg);
}
`
Every program must have a function with id 0, that is main or recv_internal function.
func --help
ничего такого нет, но есть в fift --help
флаг -L
import nacl from 'tweetnacl';
const keyPair = nacl.sign.keyPair.fromSecretKey(secretKey)
const keyPair = await tonMnemonic.mnemonicToKeyPair(mnemonic);
keyPair.secretKey
nacl.sign.keyPair.fromSecretKey
все 64 байта, то он просто оставляет 32 последних (я пробовал их менять, и изменения переносятся)
xcrun --show-sdk-path- что это показывает?
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk
CC="clang -mcpu=apple-a14" CXX="clang++ -mcpu=apple-a14" cmake .. -DCMAKE_BUILD_TYPE=Release -DTON_ARCH= -Wno-dev -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3 -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/вот в этой инструкции поменяй
CC="clang -mcpu=apple-a14" CXX="clang++ -mcpu=apple-a14" cmake .. -DCMAKE_BUILD_TYPE=Release -DTON_ARCH= -Wno-dev -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3 -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk
func: ton/build/crypto/func
fift: ton/build/crypto/fift
lite-client: build/lite-client/lite-client
func: ton/crypto/func
fift: ton/crypto/fift
lite-client: ton/build/lite-client/
(и тут кстати нету подпапки lite-client)
/usr/local/bin
и тогда toncli будет доступен глобально. Я правильно понял?
/usr/local/bin
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/Git/ton/ton/build/lite-client:/usr/Git/ton/ton/crypto
slice get_wallet_address(slice owner_address) method_id {
(int total_supply, slice admin_address, cell content, cell jetton_wallet_code) = load_data();
return calculate_user_jetton_wallet_address(owner_address, my_address(), jetton_wallet_code);
}
const ownerAddress = new tonweb.Address(ownerAddress).toString(true, true, true)
const result = await this.httpProvider.call2(
jettonMinterAddress.toString(true, true, true),
"get_wallet_address",
[["slice", ownerAddress]],
)
get_data()
?
Stores (serializes) an integer x in the range 0..2^128 − 1 into builder b. The serialization of x consists of a 4-bit unsigned big-endian integer l, which is the smallest integer l ≥ 0, such that x < 2^8l, followed by an 8l-bit unsigned big-endian representation of x. If x does not belong to the supported range, a range check exception is thrown.это из описания func store_grams
nanograms swap STGRAMS
вроде сработало
slice data = begin_cell().store_uint(index, 32).end_cell().begin_parse();
randomize_lt();
int totalSize = maxSupply - total_supply;
int index = rand(totalSize);
int value = 0;
;; Pick id
(slice existing, int found) = cache.udict_get?(32, index);
if (found) {
value = existing~load_uint(32);
} else {
value = index;
}
;; Dict continuity
(slice tailValue, int foundTail) = cache.udict_get?(32, totalSize - 1);
if (foundTail) {
cache~udict_set(32, index, tailValue);
} else {
cache~udict_set_builder(32, index, begin_cell().store_uint(totalSize - 1, 32));
}
;; Cleanup tail
cache~udict_delete?(32, totalSize);
rand
должен инклюзивно генерить
function randomIndex() internal returns (uint256) {
uint256 totalSize = TOKEN_LIMIT - totalSupply();
uint256 index = uint(keccak256(abi.encodePacked(nonce, msg.sender, block.difficulty, block.timestamp))) % totalSize;
uint256 value = 0;
if (indices[index] != 0) {
value = indices[index];
} else {
value = index;
}
if (indices[totalSize - 1] == 0) {
indices[index] = totalSize - 1;
} else {
indices[index] = indices[totalSize - 1];
}
nonce++;
return value.add(1);
}
cannot apply external message to current state : failed to parse external message external message must begin with ext_in_msg_info$10
<b
lc_address 256 u,
address 256 u,
nanograms swap STGRAMS
b>
2 boc+>B
saveboc
ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
import_fee:Grams = CommonMsgInfo;
48865717417326510572597755101274591274554285053593344447155073148062282427337
30871574573638575395419991697340249419098489764945262626281871598522621360359
public_key
и subwallet_id
не зашиваются программой-деплоером в код контракта в виде констант?8000000000000000
в тестнете?
export declare type ExecutionResult = FailedExecutionResult | SuccessfulExecutionResult;