Skip to content

luuthanhminh/Golang-Ethereum-Personal-Sign

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Ethereum Personal Sign

Go Reference Go Report Card

A simple Golang solution for MetaMasks personal_sign method (https://docs.metamask.io/guide/signing-data.html#a-brief-history). Create a MetaMask signature for comparison: https://app.mycrypto.com/sign-message

Usage

Install:

go get github.com/etaaa/Golang-Ethereum-Personal-Sign

Usage:

package main

import (
	"fmt"
	"log"
	"os"
	"testing"

	"github.com/ethereum/go-ethereum/crypto"
	"github.com/joho/godotenv"

	ps "github.com/etaaa/Golang-Ethereum-Personal-Sign"
)

func main() {
	// Load private key from .env file
	err := godotenv.Load()
	if err != nil {
		log.Fatal(err)
	}
	privateKeyString := os.Getenv("PRIVATE_KEY")
	// Parse private key
	privateKey, err := crypto.HexToECDSA(privateKeyString)
	if err != nil {
		log.Fatal(err)
	}
	// Sign message
	signature, err := ps.PersonalSign("Hello World.", privateKey)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(signature)
}

Questions

For any questions feel free to DM me on Discord (@itseta).

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

MIT

About

A simple Golang solution for MetaMasks personal_sign method

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%