joinSignature

Learn about the joinSignature utils method

Learn about the joinSignature utils method

Introduction

The joinSignature method is used to combine separate parts of an Ethereum signature into a single hex string. The signature parts must be in a specific order for this method to work.

Usage

This method should be used when you have separate parts of an Ethereum signature and you want to combine them into a single hex string.

Here’s a simple code example to demonstrate how to use this method:

Javascript
1const { Utils } = require("alchemy-sdk");
2
3// Expanded-format; this is the format Solidity and other tools often require
4let expanded = {
5 r: "0x0ba9770fd8778383f6d56faadc71e17b75f0d6e3ff0a408d5e6c4cee3bd70a16",
6 s: "0x3574da0ebfb1eaac261698b057b342e52ea53f85287272cea471a4cda41e3466",
7 recoveryParam: 0,
8 v: 27,
9};
10let flat = Utils.joinSignature(expanded);
11
12console.log(flat);
13
14// 0x0ba9770fd8778383f6d56faadc71e17b75f0d6e3ff0a408d5e6c4cee3bd70a163574da0ebfb1eaac261698b057b342e52ea53f85287272cea471a4cda41e34661b