Last active
March 25, 2024 16:29
-
-
Save teghnet/1535a11b6ae2c0e3af1cb57dc57a1309 to your computer and use it in GitHub Desktop.
This is how you can sign a message with an embedded RPC server in frame.sh using https://github.com/defiweb/go-eth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/defiweb/go-eth/rpc" | |
"github.com/defiweb/go-eth/rpc/transport" | |
"github.com/defiweb/go-eth/types" | |
"github.com/defiweb/go-eth/wallet" | |
) | |
func main() { | |
t, err := transport.NewHTTP(transport.HTTPOptions{URL: "http://127.0.0.1:1248"}) | |
if err != nil { | |
panic(err) | |
} | |
c, err := rpc.NewClient(rpc.WithTransport(t)) | |
if err != nil { | |
panic(err) | |
} | |
a := types.MustAddressFromHex("0x1234567890123456789012345678901234567890") | |
m, err := wallet.NewKeyRPC(c, a).SignMessage(context.Background(), []byte("data")) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(m) | |
s, err := c.Sign(context.Background(), a, []byte("data")) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of course, this requires you to have the key (signer) for the above mentioned address configured in frame.sh