Skip to content

Instantly share code, notes, and snippets.

@MariusVanDerWijden
Created July 8, 2020 09:14
Show Gist options
  • Save MariusVanDerWijden/1d599de41a326cd97eabdd346290ae11 to your computer and use it in GitHub Desktop.
Save MariusVanDerWijden/1d599de41a326cd97eabdd346290ae11 to your computer and use it in GitHub Desktop.
// Use secret key hex string to sign a raw transaction
SK := "0x0000"
sk := crypto.ToECDSAUnsafe(common.FromHex(SK))// Sign the transaction
signedTx, err := types.SignTx(tx, types.NewEIP155Signer(nil), sk)
// You could also create a TransactOpts object
opts := bind.NewKeyedTransactor(sk)
// To get the address corresponding to your private key
addr := crypto.PubkeyToAddress(sk.PublicKey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment