Function ethers_providers::call_raw::spoof::code
source · pub fn code(adr: H160, code: Bytes) -> State
Expand description
Returns a state override set with a single element setting the code at the address.
§Examples
ⓘ
let geth = Geth::new().spawn();
let provider = Provider::<Http>::try_from(geth.endpoint()).unwrap();
let adr: Address = "0x6fC21092DA55B392b045eD78F4732bff3C580e2c".parse()?;
let pay_amt = parse_ether(1u64)?;
let tx = TransactionRequest::default().to(adr).into();
// override the code at the target address
let state = spoof::code(adr, "0x00".parse()?);
provider.call_raw(&tx).state(&state).await?;