Skip to content

Files

Latest commit

bae9bfd · Feb 6, 2025

History

History

web3-signature

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 17, 2022
Oct 25, 2023
Jan 17, 2023
Mar 23, 2023
Jul 24, 2024
Jul 24, 2019
Nov 8, 2023
Feb 6, 2025
Oct 13, 2022
Oct 13, 2022
Sep 27, 2023

@requestnetwork/web3-signature

Web3 Signature Provider.

@requestnetwork/web3-signature is a typescript library part of the Request Network protocol.

Implementation of the signature provider from the web3 tools. The signature provider is used to make signature in the Request Network Protocol (e.g.: see Request Logic). This provider allows users to use Metamask to sign data.

It uses the Request Network Protocol concepts of Identity and Signature described in the request logic specification.

Installation

npm install @requestnetwork/web3-signature

Usage

import {
  IdentityTypes,
  SignatureTypes
} from '@requestnetwork/types'

import Web3SignatureProvider from '@requestnetwork/web3-signature'

// Identity from the previous signature parameter
const identityExample: IdentityTypes.IIdentity = {
  type: IdentityTypes.TYPE.ETHEREUM_ADDRESS,
  value: '0x627306090abab3a6e1400e9345bc60c78a8bef57'
};

// Construct the provider with a
const signatureProvider = new Web3SignatureProvider(web3.currentProvider);

// can sign data with identity
const dataToSign = { ... };
const signedData = signatureProvider.sign(dataToSign, identityExample);
/*
{
  data: { ... },
  signature: {
    method: SignatureTypes.METHOD.ECDSA,
    value: '0x...'
  }
}
*/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Read the contributing guide

License

MIT