/
ton-org
/
blueprint
Обзор
Документация
Войти
/
ton-org
/
blueprint
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
develop
example/scripts/incrementCounter.ts
37 строк
1 KB
KardanovIR
Updated all dependencies to @ton organization packages
30 июл 2023, 00:52
30 июл 2023, 00:52
ef89a7e
Код
Авторство
О чём код?
import { Address, toNano } from '@ton/core'; import { Counter } from '../wrappers/Counter'; import { NetworkProvider, sleep } from '@ton/blueprint'; export async function run(provider: NetworkProvider, args: string[]) { const ui = provider.ui(); const address = Address.parse(args.length > 0 ? args[0] : await ui.input('Counter address')); if (!(await provider.isContractDeployed(address))) { ui.write(`Error: Contract at address ${address} is not deployed!`); return; } const counter = provider.open(Counter.createFromAddress(address)); const counterBefore = await counter.getCounter(); await counter.sendIncrease(provider.sender(), { increaseBy: 1, value: toNano('0.05'), }); ui.write('Waiting for counter to increase...'); let counterAfter = await counter.getCounter(); let attempt = 1; while (counterAfter === counterBefore) { ui.setActionPrompt(`Attempt ${attempt}`); await sleep(2000); counterAfter = await counter.getCounter(); attempt++; } ui.clearActionPrompt(); ui.write('Counter increased successfully!'); }