js-sign library allows browsers and Node.js clients to create signature payload in order to interact with Covalent API. Generally, only one function call is required to create the necessary signature.
Currently, when using some Covalent API endpoints, the only data that required signing is the wallet address.
Installation
Browser javascript
Embed the javascript source in html
<script src="https://cdn.jsdelivr.net/npm/@covalenthq/js-sign/dist/lib.min.js"></script>
Node.JS
Installing module
npm i --save @covalenthq/js-sign
Build from source
The output of the build process is located in dist folder,
npm run build
Download from github gist
- Please download the single library, covalent-js-sign.js, directly from the github gist,
https://gist.github.com/cloggo/8f1b16ef2bdcfd663e587dba11f2d116#file-covalent-js-sign-js
Testing
All new code changes should be covered with unit tests. You can run the tests with the following command,
npm run test
Configuration and Setup
Private key
Provide private key to process.env.PRIVATE_KEY variable. You can use dotenv or any other way.
process.env.PRIVATE_KEY = ${YOUR_PRIVATE_KEY}
Usage
import * as covalent from '@covalenthq/js-sign';
const privateKey = process.env.PRIVATE_KEY;
const walletAddress = "0x71d094E5382CA33B25B92d3A75d5C6f269A78fAe";
const chainId = 1;
const payload = covalent.createSignaturePayloadB64(privateKey, walletAddress, chainId);