`abigen` inline loading of ABI is failing
IlluvatarEru opened this issue · comments
Version
├── ethers v2.0.11
│ ├── ethers-addressbook v2.0.11
│ │ ├── ethers-core v2.0.11
│ ├── ethers-contract v2.0.11
│ │ ├── ethers-contract-abigen v2.0.11
│ │ │ ├── ethers-core v2.0.11 (*)
│ │ ├── ethers-contract-derive v2.0.11 (proc-macro)
│ │ │ ├── ethers-contract-abigen v2.0.11
│ │ │ │ ├── ethers-core v2.0.11
│ │ │ ├── ethers-core v2.0.11 (*)
│ │ ├── ethers-core v2.0.11 (*)
│ │ ├── ethers-providers v2.0.11
│ │ │ ├── ethers-core v2.0.11 (*)
│ ├── ethers-core v2.0.11 (*)
│ ├── ethers-etherscan v2.0.11
│ │ ├── ethers-core v2.0.11 (*)
│ ├── ethers-middleware v2.0.11
│ │ ├── ethers-contract v2.0.11 (*)
│ │ ├── ethers-core v2.0.11 (*)
│ │ ├── ethers-etherscan v2.0.11 (*)
│ │ ├── ethers-providers v2.0.11 (*)
│ │ ├── ethers-signers v2.0.11
│ │ │ ├── ethers-core v2.0.11 (*)
│ ├── ethers-providers v2.0.11 (*)
│ └── ethers-signers v2.0.11 (*)
├── ethers-contract-abigen v2.0.11 (*)
├── ethers-core v2.0.11 (*)
├── ethers-providers v2.0.11 (*)
Platform
Linux debian-10 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
Description
I am loading the abi.json directly in line (as shown here) but getting a use of undeclared type
IERC20` error when compiling.
I tried this code:
abigen!(IERC20, "./data/IERC20.json");
const RPC_URL: &str = "https://eth.llamarpc.com";
const WETH_ADDRESS: &str = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
let provider = Provider::<Http>::try_from(RPC_URL)?;
let client = Arc::new(provider);
let address: Address = WETH_ADDRESS.parse()?;
let contract = IERC20::new(address, client);
I expected to see this happen: being able to load the abi from json and use it to create a new contract instance.
Instead, this happened:use of undeclared type
IERC20` error when compiling.
Found out that there is an error depending on how is the folder named: I had my abis in /data/
folder and that is failing but works fine if reading from ./abis/
. Weird error though