Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@safe-global/safe-apps-provider

safe-global1.2mMIT0.18.6TypeScript support: included

A provider wrapper of Safe Apps SDK

readme

Safe Apps Provider

npm

This is a provider that follows common standards (e.g. EIP-1193) and can be used with various Web3 libraries (e.g. web3.js or Ethers)

How to use

  • Add npm package
yarn add @safe-global/safe-apps-provider

npm i @safe-global/safe-apps-provider

SafeAppProvider

The provider can be used with the safe-apps-react-sdk and common web3 libraries.

With Ethers.js

import React, { useMemo } from 'react';
import { ethers } from 'ethers';
import { useSafeAppsSDK } from '@safe-global/safe-apps-react-sdk';
import { SafeAppProvider } from '@safe-global/safe-apps-provider';

const App = () => {
  const { sdk, safe } = useSafeAppsSDK();
  const web3Provider = useMemo(() => new ethers.providers.Web3Provider(new SafeAppProvider(safe, sdk)), [sdk, safe]);

  // use provider with contracts

  return;
};

export default App;

With web3.js

import React, { useMemo } from 'react';
import Web3 from 'web3';
import { useSafeAppsSDK } from '@safe-global/safe-apps-react-sdk';
import { SafeAppProvider } from '@safe-global/safe-apps-provider';

const App = () => {
  const { sdk, safe } = useSafeAppsSDK();
  const web3Provider = useMemo(() => new Web3(new SafeAppProvider(safe, sdk)), [sdk, safe]);

  // use provider with contracts

  return;
};

export default App;

A note on gas limit

The ethereum transaction gas limit passed to the safe-apps-provider will be treated as safeTxGas, which is an equivalent of the ethereum transaction gas limit in the Safe context. To learn more about the safe transaction gas, read here:
https://github.com/safe-global/safe-contracts/blob/c36bcab46578a442862d043e12a83fec41143dec/docs/safe_tx_gas.md

If you don't want to pass a calculation and leave it to the Safe, pass 0 as the gas limit.

More scenarios

For the SDK overview documentation, please refer to the safe-apps-sdk documentation

changelog

@safe-global/safe-apps-provider

0.18.6

Patch Changes

  • 8036c19: Update EIP-5792 according to spec.
  • 2081b24: Update EIP-5792 implementation according to spec. and fix pending status

0.18.5

Patch Changes

  • 5219a05: Update EIP-5792 implementation according to spec. and fix pending status

0.18.4

Patch Changes

  • 21ffde5: Add EIP-5792 support

0.18.3

Patch Changes

  • 55342f0: chore: bump dependencies
  • Updated dependencies [e0710be]
  • Updated dependencies [55342f0]
  • Updated dependencies [2cc8919]

0.18.2

Patch Changes

0.18.2-next.0

Patch Changes

0.18.1

Patch Changes

  • d6baa64: fallback value and data were overwritten with undefined

0.18.0

Minor Changes

  • 077d2cc: Add sideEffects false to package.json to improve tree-shaking
  • b24cde9: chore: bump dependencies

Patch Changes

0.17.1

Patch Changes

0.17.0

Minor Changes

  • bdae5af: Signing methods return the signature instead of 0x

Patch Changes

0.16.1

Patch Changes

0.16.0

Minor Changes

  • f89c36f: Adds the new setSafeSettings and getOffChainSignature methods.

Patch Changes

0.15.2

Patch Changes

0.15.1

Patch Changes

  • b6c00b8: Convert gaslimit hex-encoded string to a decimal number

0.15.0

Minor Changes

  • 6762218: Pass the gas limit to safeTxGas when sending a transaction through the Safe app provider

0.14.0

Minor Changes

  • b7b203f: Accept string as message argument in eth_signTypedData

0.13.2

Patch Changes

  • 50853a2: Fix eth_signTypedData message params ordering

0.13.1

Patch Changes

0.13.0

Minor Changes

  • a0991c0: add support for the eip-712 signature method

Patch Changes

0.12.0

Minor Changes

  • 7c10204: Added support for EIP-2255

Patch Changes

0.11.3

Patch Changes

0.11.2

Patch Changes

0.11.1

Patch Changes

0.11.0

Minor Changes

  • df5f7ff: Add getEnvironmentInfo method and isReadOnly prop to SafeInfo

Patch Changes

0.10.3

Patch Changes

0.10.2

Patch Changes

0.10.1

Patch Changes

0.10.0

Minor Changes

  • 45199f6: Use safe-react-gateway for gateway types. Bump dependencies

Patch Changes

0.9.3

Patch Changes

0.9.2

Patch Changes

0.9.1

Patch Changes

0.9.0

Minor Changes

  • 8c1d1e4: Extend the provider from Node.js EventEmitter class

Patch Changes

0.8.1

Patch Changes

  • 2b56d7e: move unecessary dependencies to dev-dependencies
  • Updated dependencies [2b56d7e]
  • Updated dependencies [9a4d3a4]

0.8.1-next.1

Patch Changes

0.8.1-next.0

Patch Changes

0.8.0

Minor Changes

  • 8d86ff2: support eth_sign and personal_sign

Patch Changes

0.8.0-next.3

Minor Changes

  • 8d86ff2: support eth_sign and personal_sign

0.7.2-next.2

Patch Changes

0.7.2-next.1

Patch Changes

0.7.2-next.0

Patch Changes

0.7.1

Patch Changes

0.7.0

Minor Changes

  • f9d1a18: Support eth_gasPrice rpc method
  • 9f91d38: Add support for eth_getTransactionCount rpc call

Patch Changes

0.7.0-next.1

Minor Changes

  • f9d1a18: Support eth_gasPrice rpc method

Patch Changes

0.7.0-next.0

Minor Changes

  • 9f91d38: Add support for eth_getTransactionCount rpc call

Patch Changes