Skip to content

Commit

Permalink
spammer: only airdrop to active addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Oct 13, 2023
1 parent dcc997d commit 4f989b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spammer/addresslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -252,13 +253,13 @@ func Airdrop(config *Config, value *big.Int) error {
fmt.Printf("error getting chain ID; could not airdrop: %v\n", err)
return err
}
for _, addr := range addrs {
for _, addr := range config.keys {
nonce, err := backend.PendingNonceAt(context.Background(), sender)
if err != nil {
fmt.Printf("error getting pending nonce; could not airdrop: %v\n", err)
return err
}
to := common.HexToAddress(addr)
to := crypto.PubkeyToAddress(addr.PublicKey)
gp, _ := backend.SuggestGasPrice(context.Background())
tx2 := types.NewTransaction(nonce, to, value, 21000, gp, nil)
signedTx, _ := types.SignTx(tx2, types.LatestSignerForChainID(chainid), config.faucet)
Expand All @@ -267,6 +268,7 @@ func Airdrop(config *Config, value *big.Int) error {
return err
}
tx = signedTx
time.Sleep(10 * time.Millisecond)
}
// Wait for the last transaction to be mined
if _, err := bind.WaitMined(context.Background(), backend, tx); err != nil {
Expand Down

0 comments on commit 4f989b0

Please sign in to comment.