Closed skimaharvey closed 2 years ago
Hi @skimaharvey, can you provide reproduction steps or a minimal reproducible example?
I was having the same problem too.
We're deploying to polygon and I never had trouble deploying locally. When I tried to setup a CI pipeline is when i started getting the error. Had someone else clone the project and they started getting the same error too. I can't replicate it locally and we both use macs.
After playing with the deploy script and creating this minimal version, I found that it was the matic.balanceOf(adminAddress)
call that was breaking things.
After replacing all those calls with the ethers Wallet getBalance, the rest of the script ran and was able to deploy.
Matic token contract from here lives next to our other contracts and everything complied fine.
/* External imports */
import { ethers } from 'hardhat'
import {
BigNumber,
Wallet
} from 'ethers'
import 'dotenv/config'
/* Internal imports */
import {MaticToken} from "../types";
let provider = new ethers.providers.JsonRpcProvider(
process.env.INFURA_URL
)
let privateKey1: string = process.env.PRIVATE_KEY as string
let l1Wallet1: Wallet = new ethers.Wallet(privateKey1, provider)
const adminAddress = l1Wallet1.address
let matic: MaticToken
let adminMaticBalanceBefore: BigNumber
async function main() {
console.log('wallet', l1Wallet1)
matic = await ethers.getContractAt(
'IERC20',
'0x0000000000000000000000000000000000001010'
) as MaticToken
console.log('matic', matic)
const balance = await l1Wallet1.getBalance()
// works
console.log('balance', balance)
// does not work in CI
adminMaticBalanceBefore = await matic.balanceOf(adminAddress)
console.log('adminMaticBalanceBefore', adminMaticBalanceBefore)
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
@skimaharvey if you are using the .env.template
, make sure you rename it from .env.template to .env
. It sounds to me like maybe you have an Infura URL or similar configured for RINKEBY_URL and it is maybe undefined which is throwing in the fetch call.
Uhm, this seems like a config validation issue we are not catching. Again: if someone can provide reproduction steps, it would be very useful.
Got the same issue here, the contract was compiled with no errors, but when atempt to deploy on ropsten network I get the error code, file is in /Users/computer/my-nft/node_modules/loupe/index.js :
ypeError: Only absolute URLs are supported
at getNodeRequestOptions (/Users/computer/my-nft/node_modules/node-fetch/lib/index.js:1327:9)
at /Users/computer/my-nft/node_modules/node-fetch/lib/index.js:1440:19
at new Promise (
Again: nothing we can do here without a minimal reproducible example. Sorry.
Closing this for now. If someone has precise and minimal reproduction steps, please let us know.
Keep closed but: Ended up in this thread because of a colleague not copying the .env.example to .env, ended up using empty string for mainnet url to fork with hardhat. So definitely not really a hardhat error, should be a clearer error message maybe, but user error ;)
Oh that's really interesting @cpecorari. I will open a new issue for that.
I had this same issue trying to run a smart contract on a docker environment, I used Alchemy node and named a respiratory with the same GitHub respiratory name, but I used the docker start up alpine git I found the question raised in many places all talking about the "fetch" command. Honestly, I don't know where to find or add the fetch command, in what file?
@Shymaa-Arafat this error usually happens because the URL used was an empty string or some filler value like "url". Read the discussion in this issue for the details.
Hello,
Here is the error i get when I try to deploy my contracts to rinkeby. No problem during compilation. I am confused about it. Any help is appreciated. Thank you.