Working with Electrum: Generating Scripthashes from addresses

Working with Electrum: Generating Scripthashes from addresses
Photo by Kelly Sikkema / Unsplash

Electrum is a great way to interact with Bitcoin like blockchains without having to download the whole chain yourself. It allows for something called a light client.
This lightness however comes with a small, but consequential pitfall.

The Problem

How do you generate Scripthashes?

Scriphashes are not your regular addresses or public keys.

p92W3t7YkKfQEPDb7cG9jQ6iMh7cpKLvwK

A (multigsig) Peercoin address

f83cf3b3ccddc19323fccef53417926f3303070abf4c6492164d2b0f513ad4e6

Its respective coin hash

They are their own special format to make procceses inside of Electrum servers easier. Depending on the programming language you're using, it can be very cumbersome to convert addresses internally into Electrum-compliant Scripthashes.

Electrum Documentation

The Solution

Utilizing a Scripthash generator

We have developed two solutions for you.

Solution 1

Using dart_scripthash_generator, a CLI-tool which will return you the Scripthash for a given network, presently Bitcoin, Peercoin and their respective testnets.
This tool requires you to have Dart installed.


Solution 2

Using dart_scripthash_server, a dockerized microservice, which provides a simple endpoint to query Scripthashes fast and reliably. All you need is Docker or docker-compose.

We hope you found this useful!