@@ -233,15 +233,22 @@ var (
233233` )
234234
235235 evmNodesFundExample = cli .Examples (`
236- # Fund all nodes with at least 0.5 ETH on chain 1 in staging
237- exemplar evm nodes fund --environment staging --selector 1 --amount 0.5 --1559
236+ # Fund all nodes with at least 0.5 ETH on chain 1 in staging (using --eth flag)
237+ exemplar evm nodes fund --environment staging --selector 1 --eth 0.5 --1559
238+
239+ # Fund all nodes with 100 ETH
240+ exemplar evm nodes fund --environment staging --selector 1 --eth 100
241+
242+ # Fund all nodes with specific wei amount (using --amount flag)
243+ exemplar evm nodes fund --environment staging --selector 1 --amount 10000000000000000000
238244` )
239245)
240246
241247func (c Commands ) newEvmNodesFund (domain domain.Domain ) * cobra.Command {
242248 var (
243- amountStr string
244- use1559 bool
249+ ethAmount string
250+ weiAmount string
251+ use1559 bool
245252 )
246253
247254 cmd := cobra.Command {
@@ -252,6 +259,15 @@ func (c Commands) newEvmNodesFund(domain domain.Domain) *cobra.Command {
252259 RunE : func (cmd * cobra.Command , args []string ) error {
253260 envKey , _ := cmd .Flags ().GetString ("environment" )
254261 chainselector , _ := cmd .Flags ().GetUint64 ("selector" )
262+
263+ // Check that exactly one of --eth or --amount is provided
264+ if ethAmount != "" && weiAmount != "" {
265+ return errors .New ("cannot use both --eth and --amount flags. Use --eth for ETH amounts (e.g., --eth 10) or --amount for wei amounts" )
266+ }
267+
268+ if ethAmount == "" && weiAmount == "" {
269+ return errors .New ("either --eth or --amount flag is required. Use --eth for ETH amounts (e.g., --eth 10) or --amount for wei amounts" )
270+ }
255271
256272 env , err := environment .Load (cmd .Context (), domain , envKey ,
257273 environment .WithLogger (c .lggr ),
@@ -264,13 +280,24 @@ func (c Commands) newEvmNodesFund(domain domain.Domain) *cobra.Command {
264280 return fmt .Errorf ("chain not found for selector %d" , chainselector )
265281 }
266282 chain := env .BlockChains .EVMChains ()[cs .Selector ]
267- // Parse amount as ETH and convert to wei
268- targetAmountEth , success := big .NewFloat (0 ).SetString (amountStr )
269- if ! success {
270- return errors .New ("invalid amount" )
283+
284+ var targetAmount * big.Int
285+ if ethAmount != "" {
286+ // Parse amount as ETH and convert to wei
287+ targetAmountEth , success := big .NewFloat (0 ).SetString (ethAmount )
288+ if ! success {
289+ return errors .New ("invalid ETH amount" )
290+ }
291+ targetAmountWei := new (big.Float ).Mul (targetAmountEth , big .NewFloat (params .Ether ))
292+ targetAmount , _ = targetAmountWei .Int (nil )
293+ } else {
294+ // Parse amount as wei
295+ var success bool
296+ targetAmount , success = big .NewInt (0 ).SetString (weiAmount , 10 )
297+ if ! success {
298+ return errors .New ("invalid wei amount" )
299+ }
271300 }
272- targetAmountWei := new (big.Float ).Mul (targetAmountEth , big .NewFloat (params .Ether ))
273- targetAmount , _ := targetAmountWei .Int (nil )
274301 for _ , node := range env .NodeIDs {
275302 chainConfigs , err := env .Offchain .ListNodeChainConfigs (cmd .Context (),
276303 & nodev1.ListNodeChainConfigsRequest {
@@ -314,7 +341,8 @@ func (c Commands) newEvmNodesFund(domain domain.Domain) *cobra.Command {
314341 },
315342 }
316343
317- cmd .Flags ().StringVarP (& amountStr , "amount" , "a" , "" , "Target amount in ETH to ensure for each node (e.g., 10 for 10 ETH)" )
344+ cmd .Flags ().StringVar (& ethAmount , "eth" , "" , "Target amount in ETH to ensure for each node (e.g., 10 for 10 ETH)" )
345+ cmd .Flags ().StringVarP (& weiAmount , "amount" , "a" , "" , "Target amount in wei to ensure for each node (e.g., 10000000000000000000 for 10 ETH)" )
318346 cmd .Flags ().BoolVar (& use1559 , "1559" , false , "Use EIP-1559 transaction" )
319347
320348 return & cmd
0 commit comments