Difference Between ethers.wallet(privateKey, provider) and provider.getSigner() #2498
-
const signer = provider.getSigner();
provider.getSigner() I am a bit confused between both of them, are they the same thing??
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Whereas
|
Beta Was this translation helpful? Give feedback.
ethers.wallet(privateKey, provider)
essentially creates a wallet instance with the private key; theprovider
parameter is optional, but for precision (specificity) we additionally useprovider
, which essentially "connects" the wallet instance with theprovider
.Whereas
provider.getSigner()
returns theJsonRpcSigner
(or put simply, signer) which is connected to theprovider
(which essentially is an Ethereum node, e.g. MetaMask).ethers.getContract(address,deployer)
returns the contract (serves as a getter function for the contract) at addressaddress
and with the interface (optional, for specificity)deployer
.ethers.Contract(address, abi, signer
) -- (some context,Contract
is an objec…