lock-token.ts 1.0 KB

1234567891011121314151617181920212223242526
  1. import { init_lcd, execute_contract, query_contract } from './utils';
  2. async function script() {
  3. if (process.argv.length < 5) {
  4. console.log('Required 3 params TOKEN_CONTRACT, WORMHOLE_CONTRACT, integer AMOUNT');
  5. }
  6. let token_contract = process.argv[2];
  7. let wormhole_contract = process.argv[3];
  8. let amount = process.argv[4];
  9. let allowanceResult = await execute_contract(token_contract, {increase_allowance: {spender: wormhole_contract, amount}});
  10. if (allowanceResult == null) return;
  11. console.log('Allowance increased');
  12. let lockResult = await execute_contract(wormhole_contract, {lock_assets: {
  13. asset: token_contract,
  14. amount,
  15. recipient: Buffer.from('00000000000000000000000019a4437E2BA06bF1FA42C56Fb269Ca0d30f60716', 'hex').toString('base64'),
  16. target_chain: 2, // Ethereum
  17. nonce: Date.now() % 1000000
  18. }});
  19. if (lockResult == null) return;
  20. console.log('Tokens locked');
  21. }
  22. init_lcd(process.argv[5]);
  23. script();