Skip to content

Instantly share code, notes, and snippets.

@teghnet
Last active March 25, 2024 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teghnet/1535a11b6ae2c0e3af1cb57dc57a1309 to your computer and use it in GitHub Desktop.
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
Copy link
Author

teghnet commented Mar 25, 2024

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