Open Auth Signer SDK

Open Auth signer is signer class initiated with a users' authenticated session data and wallet address, providing methods to sign messages, transactions and send transactions form a user's social wallet.

Since the Open Auth Signer also implements from ethers Signer class, all methods in the supported ethers v6 Signer are available for use. Users will be able to access all of them without storing or having the risk of compromising their wallet private keys.

Installation

npm i @aarc-xyz/ethers-v6-signer

Initialising

import { AarcEthersSigner, OpenAuthProvider } from "@aarc-xyz/ethers-v6-signer";

const rpc_url = 'your rpc url here';
const sessionKey = localStorage.getItem('sessionKey');

const signer = new AarcEthersSigner(rpc_url,
                    {
                        apiKeyId: process.env.AARC_API_KEY,
                        wallet_address: '<authenticated address>',
                        sessionKey: sessionKey,
                        chainId: 1
                    }
                );

AarcEthersSigner takes in two parameter when initialised, rpc_url and AarcBaseProps

  • rpc_url: RPC endpiont for the corresponding chain id.

AarcBaseProps contains following required parameters.

  • apiKeyId: is your API key for the Open Auth services.

  • wallet_address: Is the authenticated address of the user's wallet, this is address is returned on success when the user first authenticates using our OpenAuth Widget.

  • sessionKey: Is a unique identifier for the user's session which is stored in local browser storage after successful authentication.

  • chainId: is the ID of the Ethereum network you want to interact with. For the mainnet, this is 1.

Signing Message

Since AarcEthersSigner implements ethers V6 Signer class, signing is as straight forward as it is in ethers.

To sign a message, use the signMessage method:

const message = "Hello, world!";
const signature = await signer.signMessage(message);

Signing Transaction

To sign a transaction, use signTransaction method:

const transaction = {
  to: "0x...",
  value: ethers.utils.parseEther("1.0"),
  gasLimit: 21000,
  // other transaction fields...
};

const signedTransaction = await signer.signTransaction(transaction);

Send Transaction

To send a transaction, use sendTransaction method:

const transaction = {
  to: "0x...",
  value: ethers.utils.parseEther("1.0"),
  gasLimit: 21000,
  // other transaction fields...
};

const transactionResponse = await signer.sendTransaction(transaction);

Last updated