Skip to content

Difference Between ethers.wallet(privateKey, provider) and provider.getSigner() #2498

Answered by krakxn
OmarWaqar123 asked this question in Q&A
Discussion options

You must be logged in to vote
  1. ethers.wallet(privateKey, provider) essentially creates a wallet instance with the private key; the provider parameter is optional, but for precision (specificity) we additionally use provider, which essentially "connects" the wallet instance with the provider.

Whereas provider.getSigner() returns the JsonRpcSigner (or put simply, signer) which is connected to the provider (which essentially is an Ethereum node, e.g. MetaMask).

  1. ethers.getContract(address,deployer) returns the contract (serves as a getter function for the contract) at address address and with the interface (optional, for specificity) deployer.

ethers.Contract(address, abi, signer) -- (some context, Contract is an objec…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@OmarWaqar123
Comment options

@krakxn
Comment options

@OmarWaqar123
Comment options

@krakxn
Comment options

Answer selected by OmarWaqar123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants