Replies: 2 comments 5 replies
-
@Beefy-py Okay Shift to latest version of ethers js then try this you can also check this thread #https://ethereum.stackexchange.com/questions/144451/typ@https://ethereum.stackexchange.com/questions/144451/typeerror-cannot-read-properties-of-undefined-reading-jsonrpcprovider if works make sure marked as Answered //importing thers and JsonRpcProvider
const { ethers, JsonRpcProvider } = require('ethers');
const fs = require('fs-extra');
async function main() {
// Json Rpc Provider - Connecting to local blockchain
const provider = new JsonRpcProvider('address'); // add your rpc server url from Ganache
// Connect to wallet to sign transactions
const wallet = new ethers.Wallet(
'Add your private key here',
provider
);
//Read ABI which you get post compilation using solc
const abi = fs.readFileSync('./fileName.abi', 'utf8');
//Read Binary which you get post compilation using solc
const binary = fs.readFileSync(
'./fileName.bin',
'utf8'
);
//Create Contract factory object to deploy
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log('Deploying, Please wait...');
// Deploy and you are good to go
const contract = await contractFactory.deploy();
console.log(contract);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); |
Beta Was this translation helpful? Give feedback.
5 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I run
node deploy.js
I get the following error:I then checked ethers' docs and I saw the for version six, ethers is imported like so
import {ethers} from 'ethers'
. So, I downgraded to ethers@5.7.2 and rannode deploy.js
again.I then got this error:
I have downloaded the ganache software and it's running.
My rpc url does look different than the one in the video.
I have the following setup in the main function...
What's going on here?
Beta Was this translation helpful? Give feedback.
All reactions