https://github.com/base/usbwallet
https://github.com/base/usbwallet
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/base/usbwallet
- Owner: base
- License: lgpl-3.0
- Created: 2025-07-09T10:59:25.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-11T00:32:41.000Z (11 months ago)
- Last Synced: 2025-07-11T05:56:33.615Z (11 months ago)
- Language: Go
- Size: 160 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# usbwallet
Fork of go-ethereum's [usbwallet package](https://github.com/ethereum/go-ethereum/tree/master/accounts/usbwallet)
with support for:
- non-HID devices (recent Trezor firmware)
- EIP-712 typed-data signatures
- Personal message signatures
Should be a drop-in replacement.
### Usage
```go
package main
import (
"fmt"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/signer/core/apitypes"
"github.com/base/usbwallet"
)
func main() {
hub, _ := usbwallet.NewTrezorHubWithWebUSB()
wallet := hub.Wallets()[0]
_ = wallet.Open("")
path, _ := accounts.ParseDerivationPath("m/44'/60'/0'/0/0")
account, _ := wallet.Derive(path, true)
data := apitypes.TypedData{
Types: map[string][]apitypes.Type{
"EIP712Domain": {{Name: "name", Type: "string"}},
"Mail": {{Name: "from", Type: "string"}, {Name: "to", Type: "string"}, {Name: "contents", Type: "string"}},
},
PrimaryType: "Mail",
Domain: apitypes.TypedDataDomain{Name: "example mail"},
Message: map[string]interface{}{"from": "from@example.com", "to": "to@example.com", "contents": "hello world"},
}
sig, _ := wallet.SignTypedData(account, data)
fmt.Printf("Sig: 0x%x\n", sig)
}
```