diff --git a/ethers-core/src/utils/anvil.rs b/ethers-core/src/utils/anvil.rs index c58230d37e..32b5b493e8 100644 --- a/ethers-core/src/utils/anvil.rs +++ b/ethers-core/src/utils/anvil.rs @@ -272,7 +272,7 @@ impl Anvil { } if is_private_key && line.starts_with('(') { - let key_str = &line[6..line.len() - 1]; + let key_str = line.split("0x").last().unwrap_or_else(|| panic!("could not parse private key: {}", line)).trim(); let key_hex = hex::decode(key_str).expect("could not parse as hex"); let key = K256SecretKey::from_bytes(&GenericArray::clone_from_slice(&key_hex)) .expect("did not get private key"); @@ -293,4 +293,9 @@ mod tests { fn can_launch_anvil() { let _ = Anvil::new().spawn(); } + + #[test] + fn can_launch_anvil_with_more_accounts() { + let _ = Anvil::new().arg("--accounts").arg("20").spawn(); + } }