https://github.com/etaaa/golang-ethereum-personal-sign
A simple Golang solution for MetaMasks personal_sign method
https://github.com/etaaa/golang-ethereum-personal-sign
ethereum go golang metamask personal-sign sign signature
Last synced: 6 months ago
JSON representation
A simple Golang solution for MetaMasks personal_sign method
- Host: GitHub
- URL: https://github.com/etaaa/golang-ethereum-personal-sign
- Owner: etaaa
- License: mit
- Created: 2022-07-02T13:39:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-15T21:26:29.000Z (over 2 years ago)
- Last Synced: 2024-11-15T04:51:51.596Z (11 months ago)
- Topics: ethereum, go, golang, metamask, personal-sign, sign, signature
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 22
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Golang Ethereum Personal Sign
[](https://pkg.go.dev/github.com/etaaa/Golang-Ethereum-Personal-Sign)
[](https://goreportcard.com/report/github.com/etaaa/Golang-Ethereum-Personal-Sign)A simple Golang solution for MetaMasks personal_sign method ().
Create a MetaMask signature for comparison: https://app.mycrypto.com/sign-message## Usage
Install:
```bash
go get github.com/etaaa/Golang-Ethereum-Personal-Sign
```
Usage:
```go
package mainimport (
"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](https://choosealicense.com/licenses/mit/)