2020-11-18 16:34:18 +01:00
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/naming-convention */
const { Random } = require ( "@cosmjs/crypto" ) ;
const { Bech32 } = require ( "@cosmjs/encoding" ) ;
2020-11-19 13:01:08 +01:00
const { coins } = require ( "@cosmjs/launchpad" ) ;
const { DirectSecp256k1HdWallet } = require ( "@cosmjs/proto-signing" ) ;
const { assertIsBroadcastTxSuccess , SigningStargateClient } = 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 ( ) {
2020-11-19 13:01:08 +01:00
const wallet = await DirectSecp256k1HdWallet . fromMnemonic ( faucet . mnemonic , undefined , prefix ) ;
2021-01-12 16:14:25 +01:00
const client = await SigningStargateClient . connectWithSigner ( rpcUrl , wallet ) ;
2020-11-19 13:01:08 +01:00
const recipient = Bech32 . encode ( prefix , Random . getBytes ( 20 ) ) ;
2020-11-18 16:34:18 +01:00
const amount = coins ( 226644 , "ucosm" ) ;
const memo = "Ensure chain has my pubkey" ;
2020-11-19 13:01:08 +01:00
const sendResult = await client . sendTokens ( faucet . address0 , recipient , amount , memo ) ;
2020-11-18 16:34:18 +01:00
assertIsBroadcastTxSuccess ( sendResult ) ;
}
main ( ) . then (
( ) => process . exit ( 0 ) ,
( error ) => {
console . error ( error ) ;
process . exit ( 1 ) ;
} ,
) ;