Guest User

Untitled

a guest
May 18th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. const TonWeb = require('tonweb');
  2. const Address = TonWeb.utils.Address;
  3. const NftUtils = require('tonweb/src/contract/token/nft/NftUtils');
  4. const utils = TonWeb.utils;
  5. const Cell = TonWeb.boc.Cell;
  6. const { JettonMinter, JettonWallet } = TonWeb.token.jetton;
  7. const TonMnemonic = require('tonweb-mnemonic');
  8. const BN = require('bn.js');
  9.  
  10. const toWallet = new Address('Ef8WbMN3cjOX59wsztE5e4y9lfryzP6js7ahFpE797XOxkwA');
  11.  
  12. const tonApiKey = "";
  13. const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC', { apiKey: tonApiKey }));
  14.  
  15. const walletMnemonic = [
  16.  
  17. '', '', '',
  18. '', '', '',
  19. '', '', '',
  20. '', '', '',
  21. '', '', '',
  22. '', '', '',
  23. '', '', '',
  24. '', '', ''
  25.  
  26. ];
  27.  
  28. async function run() {
  29.  
  30. async function getWalletKeys(walletMnemonic) {
  31. return await TonMnemonic.mnemonicToKeyPair(walletMnemonic);
  32. }
  33.  
  34.  
  35. const walletKeys = await getWalletKeys(walletMnemonic);
  36.  
  37. const WalletClass = tonweb.wallet.all['v4R2'];
  38. const wallet = new WalletClass(tonweb.provider, {
  39. publicKey: walletKeys.publicKey,
  40. });
  41.  
  42. const walletAddress = await wallet.getAddress();
  43. const walletBalance = await tonweb.getBalance(walletAddress);
  44.  
  45. console.log(`wallet: ${walletAddress.toString(true, true, true)} balance: ${walletBalance} nanoTON`);
  46.  
  47.  
  48. const seqno = (await wallet.methods.seqno().call()) || 0;
  49.  
  50.  
  51. const sendKoteResult = await wallet.methods.transfer({
  52. secretKey: walletKeys.secretKey,
  53. toAddress: 'Ef8WbMN3cjOX59wsztE5e4y9lfryzP6js7ahFpE797XOxkwA',
  54. amount: TonWeb.utils.toNano(0.04),
  55. seqno: seqno,
  56. payload: null,
  57. sendMode: 32,
  58. }).send();
  59.  
  60. console.log(sendKoteResult);
  61. }
  62.  
  63. run();
Advertisement
Add Comment
Please, Sign In to add comment