-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdappWithdraw.ts
More file actions
32 lines (24 loc) · 1.07 KB
/
dappWithdraw.ts
File metadata and controls
32 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { BlockchainProgram } from '../wrappers/BlockchainProgram';
import { NetworkProvider } from '@ton-community/blueprint';
import { Address, toNano } from 'ton-core';
import { sleep } from '@ton-community/blueprint/dist/utils';
export async function run(provider: NetworkProvider, args: string[]) {
const ui = provider.ui();
const address = Address.parse(args.length > 0 ? args[0] : await ui.input('Dapp address'));
const blockchainProgram = provider.open(BlockchainProgram.createFromAddress(address));
const balanceBefore = await blockchainProgram.getStateBalance();
await blockchainProgram.sendWithdrawMsg(provider.sender(), {
queryId: Date.now(),
withdrawAmount: toNano('0.05')
});
let balanceAfter = await blockchainProgram.getStateBalance();
let attempt = 1;
while (balanceBefore === balanceAfter) {
ui.setActionPrompt(`Attempt ${attempt}`);
await sleep(2000);
balanceAfter = await blockchainProgram.getStateBalance();
attempt++;
}
ui.clearActionPrompt();
ui.write('Success!');
}