Social Login Signatures

Hi everyone,

I need to be able to create signatures with the private keys generated by the Social Login feature. The use case is creating users in a CMS and logging them in automatically when they connect their wallet.

After initializing the SocialLogin class I’m trying to use the getPrivateKey function, to set up an ethers Wallet to handle the signature.

await this.socialLogin.init();

this.socialLogin.showWallet();

[...]

const key = await this.socialLogin.getPrivateKey();
const wallet = new ethers.Wallet(key);

const str = "Hello World";            
const signature = await wallet.signMessage(str);

However, when I try to connect Metamask or Wallet Connect, I get the following Error messages respectively:

Metamask:

MetaMask - RPC Error: The method "eth_private_key" does not exist / is not available.

Wallet Connect:

Uncaught (in promise) Error: Method not supported.

Any help with the error or other ideas on approaching my use case would be appreciated.

What version of ethers.js is recommended to use?

I’m getting error saying

 import error: 'ethers'.'provider' is not exported from 'ethers' (imported as 'ethers').

export 'ethers'.'provider' (imported as 'ethers') was not found in 'ethers' (possible exports: BaseContract, BigNumber, Contract, ContractFactory, FixedNumber, Signer, VoidSigner, Wallet, Wordlist, constants, errors, getDefaultProvider, logger, providers, utils, version, wordlists)

Hi, I had some problems with some versions of ethers as well.

Try 5.7.2:

"ethers": "^5.7.2"

Which version of ethers are you using ?

Any updates regarding Metamask and Wallet Connect private key?

If I am not wrong, you are trying to follow up this - Signers ?

Yes, sorry, this has been resolved already :slight_smile:

@Emery, here’s my approach:

let ethersProvider;

const signMessage = async (msg) => {
  if (!ethersProvider){ 
    ethersProvider = new ethers.providers.Web3Provider(provider, "any");
  }

  const signer = ethersProvider.getSigner();

  return await signer.signMessage(msg);
};

The provider passes into the new ethers Web3Provider can either come from web3 auth or in the case of Particle Auth like this:

if(!particleConnectKit) {
  particleConnectKit = new ParticleConnect(connectKitOptions);
}

await particleConnectKit.particle.auth.login();
provider = new ParticleProvider(particleConnectKit.particle.auth);
1 Like

right, .getsigner would work, but wallet won’t. Glad its resolved.