Network error when deplying to Alchemy Rinkebin network #255
-
Hello ! When I try to deploy a contract to the Alchemy - Rinkebin network I have this error:
My code: const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider)
const abi = fs.readFileSync('./SimpleStorage_sol_SimpleStorage.abi', 'utf8')
const binary = fs.readFileSync(
'./SimpleStorage_sol_SimpleStorage.bin',
'utf8'
)
const contractFactory = new ethers.ContractFactory(abi, binary, wallet)
console.log('Deploying, please wait...')
const contract = await contractFactory.deploy() // STOP here! Wait for the contract to be deployed
await contract.deployTransaction.wait(1)
console.log(`Contract Address: ${contract.address}`) On the .env file I have defined the RPC_URL retrieved from Alchemy and the PRIVATE_KEY retrieved from my MetaMask account. Warm regards, |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 12 replies
-
Hi Frederico! at the top did you put:
if that doesn’t work, please paste the code on the hardhat.config thanks |
Beta Was this translation helpful? Give feedback.
-
Hi @javierdash Yes at the top I have all the required libraries. Here is the full code of deploy.js:
Thank you, |
Beta Was this translation helpful? Give feedback.
-
At this stage of the lesson 5 there is no hardhat.config file so far.... The .env file:
|
Beta Was this translation helpful? Give feedback.
-
yes I did and I can see it as being part of my yarn.lock file |
Beta Was this translation helpful? Give feedback.
-
@frederico-rocha If its still not working after double checking the repo, maybe quotations makes around your private key and rpc?
|
Beta Was this translation helpful? Give feedback.
-
Could please verify that in the Alchemy Dashboard, your app is set up to Rinkeby Network? |
Beta Was this translation helpful? Give feedback.
-
Sure, here is the Alchemy Dashboard: |
Beta Was this translation helpful? Give feedback.
-
@frederico-rocha Try removing the brackets from your url in .env
as well as from your key when not starting with "0x..."
|
Beta Was this translation helpful? Give feedback.
-
What happens when you try kovan? Or a different provider like infura or moralis? |
Beta Was this translation helpful? Give feedback.
What happens when you try kovan? Or a different provider like infura or moralis?