How to add accounts to infura provider

Hi, so I’m just new to Infura.

My app works well locally but fails communicating with the contract through infura. After researching a bit. I found out that I had to setup accounts manually but I don’t know how to do this in my frontend app. I can do it easily with the console though using hard hat or truffle.

Any ideas? I’m using ethers.js to communicate with infura for my frontend app.

Thanks!

Hi @Jesse, and welcome to the Infura community!

Can you please paste your code (or send us your repo) so we can take a look at where you may be running into issues?

Hi I was also trying the same scenario.
here is my code git link: https://github.com/NagatoPeinI1/testInfura.git
if you see the

ganacheCompileandDeply.js

works file and I get value of

defaultAccount

.
But when I run

infuraCompileAndDeploy.js

I’m getting undefined for

defaultAccount
I have even tried adding account to wallet via

// const signer = web3.eth.accounts.privateKeyToAccount( // process.env.SIGNER_PRIVATE_KEY // ); // console.log(" signer: ",signer) // web3.eth.accounts.wallet.add(signer)