@skaleboarder/safe-tools
TypeScript icon, indicating that this package has built-in type declarations

0.0.24 • Public • Published

safe-tools

npm version

The SafeRelayer library allows you to implement a non-custodial sign-in system that enables in-browser transaction relay without requiring users to switch their wallets. It uses the Gnosis Safe for transaction processing and provides a seamless integration with your dApp.

Usage

Import the required modules and classes:

Import necessary modules and classes from the SafeRelayer library, ethers.js, and other required packages.

import { SafeRelayer, UserRelayerProps } from '@skaleboarder/safe-tools';
import { ethers } from 'ethers';

Create a relayer object:

Create a relayer object with the required configurations, such as signer, ethers, wallet deployer address, EnglishOwnerAdder address, network configuration, provider, and faucet function.

  const relayer = new SafeRelayer({
      ethers,
      signer: signers[1],
      walletDeployerAddress: walletDeployer.address,
      EnglishOwnerAdderAddress: deploys.EnglishOwnerAdder.address,
      networkConfig: contractNetworks,
      provider: deployer.provider!,
      faucet: async (address: string) => {
          await (await deployer.sendTransaction({
              to: address,
              value: ethers.utils.parseEther("2")
          })).wait()
      }
  })
  
  // we need to do this within the fixture so that the safe is created before the test runs
  // and when the state is snapshotted it all works.
  await relayer.ready

  // This can be used anywhere you'd usually use an ethers signer.
  const relayedEthersSigner = await relayer.wrappedSigner()

The returned signer is a drop-in replacement (a subclass) of an ethers.Signer. You can see how we use this in WAGMI

Readme

Keywords

none

Package Sidebar

Install

npm i @skaleboarder/safe-tools

Weekly Downloads

0

Version

0.0.24

License

MIT

Unpacked Size

21.6 MB

Total Files

648

Last publish

Collaborators

  • tobowers