Skip to content

Instantly share code, notes, and snippets.

@teghnet
Last active March 25, 2024 16:29
Show Gist options
  • Select an option

  • Save teghnet/1535a11b6ae2c0e3af1cb57dc57a1309 to your computer and use it in GitHub Desktop.

Select an option

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
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)
}
@teghnet

teghnet commented Mar 25, 2024

Copy link
Copy Markdown
Author

Of course, this requires you to have the key (signer) for the above mentioned address configured in frame.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment