ethereum-attestation-service / eas-sdk

Ethereum Attestation Service - TypeScript/JavaScript SDK
MIT License
95 stars 47 forks source link

Error "provider wasn't set" when calling eas.getOffchain before setting provider #88

Closed hiendv closed 5 months ago

hiendv commented 6 months ago

I understand that we need to inject a provider for legacy version detection when calling eas.getOffchain but the documentation is not made clear for this which causes the "provider wasn't set" error when people try to replicate the example.

https://github.com/ethereum-attestation-service/eas-sdk/blob/939a12ab08cbb8687517484aa3c9678c58879309/README.md?plain=1#L157-L159

From my opinion, there should be a better resolution for the provider. How about splitting signer and provider?

lbeder commented 6 months ago

Thanks for a great suggestion @hiendv. I'm not 100% sure re: default providers (e.g., it might be better to error in this case as well so that your calls aren't leaked unintentionally), but the rest is doable. We might postpone this to when we will move to esm, since using provider types creates known compatibility issues due to the way ethers is built.

hiendv commented 6 months ago

Do you mind if I make some improvements for docs/examples for now?

lbeder commented 6 months ago

Yes, of course. Please go ahead 💪

Phoeni0x commented 5 months ago

for those using hardhat scripts, you can move forward with:

const [deployer, signer] = await ethers.getSigners();
  const easSdk = new EAS(EASContractAddress, {signer} )
  const offchain = await easSdk.getOffchain();