我正在尝试在 go-ethereum 中创建原始交易,并发现了一些我正在修改的教程代码。错误是:
./transaction_raw_create.go:65:18: ts.GetRlp undefined (type types.Transactions has no field or method GetRlp)
Run Code Online (Sandbox Code Playgroud)
代码:
package main
import (
"context"
"crypto/ecdsa"
"encoding/hex"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/jimlawless/whereami"
)
func createRawTransaction() {
client, err := ethclient.Dial(infura.URL + infura.ID)
if err != nil {
fmt.Println(err.Error() + "@" + whereami.WhereAmI())
}
privateKey, err := crypto.HexToECDSA("fad9c8855b740a0b7ed4c221dbad0f33a83a49cad6b3fe8d5817ac83d38b6a19")
if err != nil {
fmt.Println(err.Error() + "@" + whereami.WhereAmI())
}
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
fmt.Println("error casting public key to …Run Code Online (Sandbox Code Playgroud)