2021-05-05 12:58:22 +02:00
#!/usr/bin/env -S yarn node
2020-11-18 16:34:18 +01:00
/* eslint-disable @typescript-eslint/naming-convention */
2021-03-24 19:18:24 +01:00
const { coins } = require ( "@cosmjs/amino" ) ;
2020-11-18 16:34:18 +01:00
const { Random } = require ( "@cosmjs/crypto" ) ;
2022-02-22 14:05:34 +01:00
const { toBech32 } = require ( "@cosmjs/encoding" ) ;
2020-11-19 13:01:08 +01:00
const { DirectSecp256k1HdWallet } = require ( "@cosmjs/proto-signing" ) ;
2021-06-15 13:52:50 +02:00
const {
2021-11-23 15:00:11 +01:00
assertIsDeliverTxSuccess ,
2021-06-15 13:52:50 +02:00
SigningStargateClient ,
calculateFee ,
} = require ( "@cosmjs/stargate" ) ;
2020-11-18 16:34:18 +01:00
2020-11-19 13:01:08 +01:00
const rpcUrl = "http://localhost:26659" ;
const prefix = "wasm" ;
2020-11-18 16:34:18 +01:00
const faucet = {
mnemonic :
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone" ,
2020-11-19 13:01:08 +01:00
address0 : "wasm1pkptre7fdkl6gfrzlesjjvhxhlc3r4gm32kke3" ,
2020-11-18 16:34:18 +01:00
} ;
async function main ( ) {
2021-04-06 17:12:43 +02:00
const wallet = await DirectSecp256k1HdWallet . fromMnemonic ( faucet . mnemonic , { prefix : prefix } ) ;
2021-04-08 13:14:09 +02:00
const client = await SigningStargateClient . connectWithSigner ( rpcUrl , wallet , { prefix : prefix } ) ;
2022-02-22 14:05:34 +01:00
const recipient = toBech32 ( prefix , Random . getBytes ( 20 ) ) ;
2020-11-18 16:34:18 +01:00
const amount = coins ( 226644 , "ucosm" ) ;
2022-02-09 22:37:15 +01:00
const fee = calculateFee ( 100_000 , "0.025ucosm" ) ;
2020-11-18 16:34:18 +01:00
const memo = "Ensure chain has my pubkey" ;
2021-06-15 13:52:50 +02:00
const sendResult = await client . sendTokens ( faucet . address0 , recipient , amount , fee , memo ) ;
2021-11-23 15:00:11 +01:00
assertIsDeliverTxSuccess ( sendResult ) ;
2020-11-18 16:34:18 +01:00
}
main ( ) . then (
( ) => process . exit ( 0 ) ,
( error ) => {
console . error ( error ) ;
process . exit ( 1 ) ;
} ,
) ;