From 6be440f2e239c852046fb03e4119fd2482e26c66 Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Thu, 27 Jun 2024 17:35:54 +0200 Subject: [PATCH 1/8] add dummy test wallet impl --- api/api.go | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/api/api.go b/api/api.go index 00570b6ec..2c42d6cc6 100644 --- a/api/api.go +++ b/api/api.go @@ -7,11 +7,13 @@ import ( "fmt" "math/big" + evmEmulator "github.com/onflow/flow-go/fvm/evm/emulator" evmTypes "github.com/onflow/flow-go/fvm/evm/types" "github.com/onflow/go-ethereum/common" "github.com/onflow/go-ethereum/common/hexutil" "github.com/onflow/go-ethereum/common/math" "github.com/onflow/go-ethereum/core/types" + "github.com/onflow/go-ethereum/crypto" "github.com/onflow/go-ethereum/eth/filters" "github.com/onflow/go-ethereum/rpc" "github.com/rs/zerolog" @@ -962,9 +964,13 @@ This is because a decision to not support this API was made either because we do ever or we don't support it at this phase. */ +var testKey, _ = crypto.HexToECDSA("6a0eb450085e825dd41cc3dd85e4166d4afbb0162488a3d811a0637fa7656abf") + // Accounts returns the collection of accounts this node manages. func (b *BlockChainAPI) Accounts() []common.Address { - return []common.Address{} + return []common.Address{ + crypto.PubkeyToAddress(testKey.PublicKey), + } } // Sign calculates an ECDSA signature for: @@ -990,7 +996,30 @@ func (b *BlockChainAPI) SignTransaction( ctx context.Context, args TransactionArgs, ) (*SignTransactionResult, error) { - return nil, errs.ErrNotSupported + + tx := types.NewTx(&types.LegacyTx{ + Nonce: uint64(*args.Nonce), + To: args.To, + Value: args.Value.ToInt(), + Gas: uint64(*args.Gas), + GasPrice: args.GasPrice.ToInt(), + Data: *args.Data, + }) + + signed, err := types.SignTx(tx, evmEmulator.GetDefaultSigner(), testKey) + if err != nil { + return nil, fmt.Errorf("error signing EVM transaction: %w", err) + } + + raw, err := signed.MarshalBinary() + if err != nil { + return nil, err + } + + return &SignTransactionResult{ + Raw: raw, + Tx: tx, + }, nil } // SendTransaction creates a transaction for the given argument, sign it @@ -999,7 +1028,12 @@ func (b *BlockChainAPI) SendTransaction( ctx context.Context, args TransactionArgs, ) (common.Hash, error) { - return common.Hash{}, errs.ErrNotSupported + signed, err := b.SignTransaction(ctx, args) + if err != nil { + return common.Hash{}, err + } + + return b.SendRawTransaction(ctx, signed.Raw) } // GetProof returns the Merkle-proof for a given account and optionally some storage keys. From 587250d3ca60f42e2d464d923513c4c9a5f1a2f5 Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:12:06 +0200 Subject: [PATCH 2/8] check for nonce else calcualte it --- api/api.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index 2c42d6cc6..044719650 100644 --- a/api/api.go +++ b/api/api.go @@ -997,13 +997,30 @@ func (b *BlockChainAPI) SignTransaction( args TransactionArgs, ) (*SignTransactionResult, error) { + nonce := uint64(0) + if args.Nonce != nil { + nonce = uint64(*args.Nonce) + } else { + num := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) + n, err := b.GetTransactionCount(ctx, *args.From, &num) + if err != nil { + return nil, err + } + nonce = uint64(*n) + } + + var data []byte + if args.Data != nil { + data = *args.Data + } + tx := types.NewTx(&types.LegacyTx{ - Nonce: uint64(*args.Nonce), + Nonce: nonce, To: args.To, Value: args.Value.ToInt(), Gas: uint64(*args.Gas), GasPrice: args.GasPrice.ToInt(), - Data: *args.Data, + Data: data, }) signed, err := types.SignTx(tx, evmEmulator.GetDefaultSigner(), testKey) From 6e2350fa0f6219bb0f4d51c321a9ba0f29b24864 Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:54:40 +0200 Subject: [PATCH 3/8] add comment --- api/api.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/api.go b/api/api.go index 044719650..0b1305f48 100644 --- a/api/api.go +++ b/api/api.go @@ -964,6 +964,7 @@ This is because a decision to not support this API was made either because we do ever or we don't support it at this phase. */ +// address: 0x2F3e28D2Ef6860Eb8e8317C237AEA4FD08c76df5 var testKey, _ = crypto.HexToECDSA("6a0eb450085e825dd41cc3dd85e4166d4afbb0162488a3d811a0637fa7656abf") // Accounts returns the collection of accounts this node manages. From 123e4f10b78ca35bfc0e587d2e34a8e52eab3649 Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:48:04 +0200 Subject: [PATCH 4/8] move to seperate file --- api/api.go | 92 ------------------------------------------- api/wallet.go | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 92 deletions(-) create mode 100644 api/wallet.go diff --git a/api/api.go b/api/api.go index 0b1305f48..6c4df6f94 100644 --- a/api/api.go +++ b/api/api.go @@ -7,13 +7,11 @@ import ( "fmt" "math/big" - evmEmulator "github.com/onflow/flow-go/fvm/evm/emulator" evmTypes "github.com/onflow/flow-go/fvm/evm/types" "github.com/onflow/go-ethereum/common" "github.com/onflow/go-ethereum/common/hexutil" "github.com/onflow/go-ethereum/common/math" "github.com/onflow/go-ethereum/core/types" - "github.com/onflow/go-ethereum/crypto" "github.com/onflow/go-ethereum/eth/filters" "github.com/onflow/go-ethereum/rpc" "github.com/rs/zerolog" @@ -964,96 +962,6 @@ This is because a decision to not support this API was made either because we do ever or we don't support it at this phase. */ -// address: 0x2F3e28D2Ef6860Eb8e8317C237AEA4FD08c76df5 -var testKey, _ = crypto.HexToECDSA("6a0eb450085e825dd41cc3dd85e4166d4afbb0162488a3d811a0637fa7656abf") - -// Accounts returns the collection of accounts this node manages. -func (b *BlockChainAPI) Accounts() []common.Address { - return []common.Address{ - crypto.PubkeyToAddress(testKey.PublicKey), - } -} - -// Sign calculates an ECDSA signature for: -// keccak256("\x19Ethereum Signed Message:\n" + len(message) + message). -// -// Note, the produced signature conforms to the secp256k1 curve R, S and V values, -// where the V value will be 27 or 28 for legacy reasons. -// -// The account associated with addr must be unlocked. -// -// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign -func (b *BlockChainAPI) Sign( - addr common.Address, - data hexutil.Bytes, -) (hexutil.Bytes, error) { - return nil, errs.ErrNotSupported -} - -// SignTransaction will sign the given transaction with the from account. -// The node needs to have the private key of the account corresponding with -// the given from address and it needs to be unlocked. -func (b *BlockChainAPI) SignTransaction( - ctx context.Context, - args TransactionArgs, -) (*SignTransactionResult, error) { - - nonce := uint64(0) - if args.Nonce != nil { - nonce = uint64(*args.Nonce) - } else { - num := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) - n, err := b.GetTransactionCount(ctx, *args.From, &num) - if err != nil { - return nil, err - } - nonce = uint64(*n) - } - - var data []byte - if args.Data != nil { - data = *args.Data - } - - tx := types.NewTx(&types.LegacyTx{ - Nonce: nonce, - To: args.To, - Value: args.Value.ToInt(), - Gas: uint64(*args.Gas), - GasPrice: args.GasPrice.ToInt(), - Data: data, - }) - - signed, err := types.SignTx(tx, evmEmulator.GetDefaultSigner(), testKey) - if err != nil { - return nil, fmt.Errorf("error signing EVM transaction: %w", err) - } - - raw, err := signed.MarshalBinary() - if err != nil { - return nil, err - } - - return &SignTransactionResult{ - Raw: raw, - Tx: tx, - }, nil -} - -// SendTransaction creates a transaction for the given argument, sign it -// and submit it to the transaction pool. -func (b *BlockChainAPI) SendTransaction( - ctx context.Context, - args TransactionArgs, -) (common.Hash, error) { - signed, err := b.SignTransaction(ctx, args) - if err != nil { - return common.Hash{}, err - } - - return b.SendRawTransaction(ctx, signed.Raw) -} - // GetProof returns the Merkle-proof for a given account and optionally some storage keys. func (b *BlockChainAPI) GetProof( ctx context.Context, diff --git a/api/wallet.go b/api/wallet.go new file mode 100644 index 000000000..aee87026d --- /dev/null +++ b/api/wallet.go @@ -0,0 +1,105 @@ +package api + +import ( + "context" + "fmt" + + evmEmulator "github.com/onflow/flow-go/fvm/evm/emulator" + "github.com/onflow/go-ethereum/common" + "github.com/onflow/go-ethereum/common/hexutil" + "github.com/onflow/go-ethereum/core/types" + "github.com/onflow/go-ethereum/crypto" + "github.com/onflow/go-ethereum/rpc" + + errs "github.com/onflow/flow-evm-gateway/api/errors" +) + +// address: 0x2F3e28D2Ef6860Eb8e8317C237AEA4FD08c76df5 +var testKey, _ = crypto.HexToECDSA("6a0eb450085e825dd41cc3dd85e4166d4afbb0162488a3d811a0637fa7656abf") + +// Accounts returns the collection of accounts this node manages. +func (b *BlockChainAPI) Accounts() []common.Address { + return []common.Address{ + crypto.PubkeyToAddress(testKey.PublicKey), + } +} + +// Sign calculates an ECDSA signature for: +// keccak256("\x19Ethereum Signed Message:\n" + len(message) + message). +// +// Note, the produced signature conforms to the secp256k1 curve R, S and V values, +// where the V value will be 27 or 28 for legacy reasons. +// +// The account associated with addr must be unlocked. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign +func (b *BlockChainAPI) Sign( + addr common.Address, + data hexutil.Bytes, +) (hexutil.Bytes, error) { + return nil, errs.ErrNotSupported +} + +// SignTransaction will sign the given transaction with the from account. +// The node needs to have the private key of the account corresponding with +// the given from address and it needs to be unlocked. +func (b *BlockChainAPI) SignTransaction( + ctx context.Context, + args TransactionArgs, +) (*SignTransactionResult, error) { + + nonce := uint64(0) + if args.Nonce != nil { + nonce = uint64(*args.Nonce) + } else { + num := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) + n, err := b.GetTransactionCount(ctx, *args.From, &num) + if err != nil { + return nil, err + } + nonce = uint64(*n) + } + + var data []byte + if args.Data != nil { + data = *args.Data + } + + tx := types.NewTx(&types.LegacyTx{ + Nonce: nonce, + To: args.To, + Value: args.Value.ToInt(), + Gas: uint64(*args.Gas), + GasPrice: args.GasPrice.ToInt(), + Data: data, + }) + + signed, err := types.SignTx(tx, evmEmulator.GetDefaultSigner(), testKey) + if err != nil { + return nil, fmt.Errorf("error signing EVM transaction: %w", err) + } + + raw, err := signed.MarshalBinary() + if err != nil { + return nil, err + } + + return &SignTransactionResult{ + Raw: raw, + Tx: tx, + }, nil +} + +// SendTransaction creates a transaction for the given argument, sign it +// and submit it to the transaction pool. +func (b *BlockChainAPI) SendTransaction( + ctx context.Context, + args TransactionArgs, +) (common.Hash, error) { + signed, err := b.SignTransaction(ctx, args) + if err != nil { + return common.Hash{}, err + } + + return b.SendRawTransaction(ctx, signed.Raw) +} From 92f6f3b2c01c3fbd0fc160e7c36ac2a7ac86b91d Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:59:44 +0200 Subject: [PATCH 5/8] add wallet api build --- api/api.go | 8 ++++++++ api/wallet.go | 35 ++++++++++++++++++++++------------- bootstrap/bootstrap.go | 6 ++++++ 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/api/api.go b/api/api.go index 6c4df6f94..3bfcb84e2 100644 --- a/api/api.go +++ b/api/api.go @@ -33,6 +33,7 @@ func SupportedAPIs( streamAPI *StreamAPI, pullAPI *PullAPI, debugAPI *DebugAPI, + walletAPI *WalletAPI, config *config.Config, ) []rpc.API { apis := []rpc.API{{ @@ -63,6 +64,13 @@ func SupportedAPIs( }) } + if walletAPI != nil { + apis = append(apis, rpc.API{ + Namespace: "eth", + Service: walletAPI, + }) + } + return apis } diff --git a/api/wallet.go b/api/wallet.go index aee87026d..dcc9c9885 100644 --- a/api/wallet.go +++ b/api/wallet.go @@ -12,16 +12,26 @@ import ( "github.com/onflow/go-ethereum/rpc" errs "github.com/onflow/flow-evm-gateway/api/errors" + "github.com/onflow/flow-evm-gateway/config" ) -// address: 0x2F3e28D2Ef6860Eb8e8317C237AEA4FD08c76df5 -var testKey, _ = crypto.HexToECDSA("6a0eb450085e825dd41cc3dd85e4166d4afbb0162488a3d811a0637fa7656abf") +type WalletAPI struct { + net *BlockChainAPI + config *config.Config +} + +func NewWalletAPI(config *config.Config, net *BlockChainAPI) *WalletAPI { + return &WalletAPI{ + net: net, + config: config, + } +} // Accounts returns the collection of accounts this node manages. -func (b *BlockChainAPI) Accounts() []common.Address { +func (w *WalletAPI) Accounts() ([]common.Address, error) { return []common.Address{ - crypto.PubkeyToAddress(testKey.PublicKey), - } + crypto.PubkeyToAddress(w.config.WalletKey.PublicKey), + }, nil } // Sign calculates an ECDSA signature for: @@ -33,7 +43,7 @@ func (b *BlockChainAPI) Accounts() []common.Address { // The account associated with addr must be unlocked. // // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign -func (b *BlockChainAPI) Sign( +func (w *WalletAPI) Sign( addr common.Address, data hexutil.Bytes, ) (hexutil.Bytes, error) { @@ -43,17 +53,16 @@ func (b *BlockChainAPI) Sign( // SignTransaction will sign the given transaction with the from account. // The node needs to have the private key of the account corresponding with // the given from address and it needs to be unlocked. -func (b *BlockChainAPI) SignTransaction( +func (w *WalletAPI) SignTransaction( ctx context.Context, args TransactionArgs, ) (*SignTransactionResult, error) { - nonce := uint64(0) if args.Nonce != nil { nonce = uint64(*args.Nonce) } else { num := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) - n, err := b.GetTransactionCount(ctx, *args.From, &num) + n, err := w.net.GetTransactionCount(ctx, *args.From, &num) if err != nil { return nil, err } @@ -74,7 +83,7 @@ func (b *BlockChainAPI) SignTransaction( Data: data, }) - signed, err := types.SignTx(tx, evmEmulator.GetDefaultSigner(), testKey) + signed, err := types.SignTx(tx, evmEmulator.GetDefaultSigner(), w.config.WalletKey) if err != nil { return nil, fmt.Errorf("error signing EVM transaction: %w", err) } @@ -92,14 +101,14 @@ func (b *BlockChainAPI) SignTransaction( // SendTransaction creates a transaction for the given argument, sign it // and submit it to the transaction pool. -func (b *BlockChainAPI) SendTransaction( +func (w *WalletAPI) SendTransaction( ctx context.Context, args TransactionArgs, ) (common.Hash, error) { - signed, err := b.SignTransaction(ctx, args) + signed, err := w.SignTransaction(ctx, args) if err != nil { return common.Hash{}, err } - return b.SendRawTransaction(ctx, signed.Raw) + return w.net.SendRawTransaction(ctx, signed.Raw) } diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index bd5883dd0..aaa864b43 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -344,11 +344,17 @@ func startServer( debugAPI = api.NewDebugAPI(trace, blocks, logger) } + var walletAPI *api.WalletAPI + if cfg.WalletEnabled { + walletAPI = api.NewWalletAPI(cfg, blockchainAPI) + } + supportedAPIs := api.SupportedAPIs( blockchainAPI, streamAPI, pullAPI, debugAPI, + walletAPI, cfg, ) From cb4df85cbf764442d900f6b433fee3ace688377e Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:59:49 +0200 Subject: [PATCH 6/8] make wallet key config --- config/config.go | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index a73d14892..3cbc8f31c 100644 --- a/config/config.go +++ b/config/config.go @@ -1,6 +1,7 @@ package config import ( + "crypto/ecdsa" "flag" "fmt" "io" @@ -16,6 +17,7 @@ import ( "github.com/onflow/flow-go/fvm/evm/types" flowGo "github.com/onflow/flow-go/model/flow" "github.com/onflow/go-ethereum/common" + gethCrypto "github.com/onflow/go-ethereum/crypto" "github.com/rs/zerolog" ) @@ -85,13 +87,37 @@ type Config struct { TracesBucketName string // TracesEnabled sets whether the node is supporting transaction traces. TracesEnabled bool + // WalletEnabled sets whether wallet APIs are enabled + WalletEnabled bool + // WalletKey used for signing transactions + WalletKey *ecdsa.PrivateKey } func FromFlags() (*Config, error) { cfg := &Config{} - var evmNetwork, coinbase, gas, coa, key, keysPath, flowNetwork, logLevel, logWriter, filterExpiry, accessSporkHosts, cloudKMSKeys, cloudKMSProjectID, cloudKMSLocationID, cloudKMSKeyRingID string - var streamTimeout int - var initHeight, forceStartHeight uint64 + var ( + evmNetwork, + coinbase, + gas, + coa, + key, + keysPath, + flowNetwork, + logLevel, + logWriter, + filterExpiry, + accessSporkHosts, + cloudKMSKeys, + cloudKMSProjectID, + cloudKMSLocationID, + cloudKMSKeyRingID, + walletKey string + + streamTimeout int + + initHeight, + forceStartHeight uint64 + ) // parse from flags flag.StringVar(&cfg.DatabaseDir, "database-dir", "./db", "Path to the directory for the database") @@ -116,13 +142,14 @@ func FromFlags() (*Config, error) { flag.StringVar(&cfg.AddressHeader, "address-header", "", "Address header that contains the client IP, this is useful when the server is behind a proxy that sets the source IP of the client. Leave empty if no proxy is used.") flag.Uint64Var(&cfg.HeartbeatInterval, "heartbeat-interval", 100, "Heartbeat interval for AN event subscription") flag.IntVar(&streamTimeout, "stream-timeout", 3, "Defines the timeout in seconds the server waits for the event to be sent to the client") - flag.Uint64Var(&forceStartHeight, "force-start-height", 0, "Force set starting Cadence height. This should only be used locally or for testing, never in production.") + flag.Uint64Var(&forceStartHeight, "force-start-height", 0, "Force set starting Cadence height. WARNING: This should only be used locally or for testing, never in production.") flag.StringVar(&filterExpiry, "filter-expiry", "5m", "Filter defines the time it takes for an idle filter to expire") flag.StringVar(&cfg.TracesBucketName, "traces-gcp-bucket", "", "GCP bucket name where transaction traces are stored") flag.StringVar(&cloudKMSProjectID, "coa-cloud-kms-project-id", "", "The project ID containing the KMS keys, e.g. 'flow-evm-gateway'") flag.StringVar(&cloudKMSLocationID, "coa-cloud-kms-location-id", "", "The location ID where the key ring is grouped into, e.g. 'global'") flag.StringVar(&cloudKMSKeyRingID, "coa-cloud-kms-key-ring-id", "", "The key ring ID where the KMS keys exist, e.g. 'tx-signing'") flag.StringVar(&cloudKMSKeys, "coa-cloud-kms-keys", "", `Names of the KMS keys and their versions as a comma separated list, e.g. "gw-key-6@1,gw-key-7@1,gw-key-8@1"`) + flag.StringVar(&walletKey, "wallet-api-key", "", "ECDSA private key used for wallet APIs. WARNING: This should only be used locally or for testing, never in production.") flag.Parse() if coinbase == "" { @@ -262,6 +289,16 @@ func FromFlags() (*Config, error) { cfg.TracesEnabled = cfg.TracesBucketName != "" + if walletKey != "" { + var k, err = gethCrypto.HexToECDSA(walletKey) + if err != nil { + return nil, fmt.Errorf("wrong private key for wallet API: %w", err) + } + + cfg.WalletKey = k + cfg.WalletEnabled = true + } + // todo validate Config values return cfg, nil } From 7c039574b1ca1075c5a3351e1b7e3f7a244c3973 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 8 Jul 2024 17:45:59 +0300 Subject: [PATCH 7/8] Implement eth_sign and add argument checks in eth_signTransaction --- api/wallet.go | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/api/wallet.go b/api/wallet.go index dcc9c9885..4c2670677 100644 --- a/api/wallet.go +++ b/api/wallet.go @@ -2,16 +2,17 @@ package api import ( "context" + "errors" "fmt" evmEmulator "github.com/onflow/flow-go/fvm/evm/emulator" + "github.com/onflow/go-ethereum/accounts" "github.com/onflow/go-ethereum/common" "github.com/onflow/go-ethereum/common/hexutil" "github.com/onflow/go-ethereum/core/types" "github.com/onflow/go-ethereum/crypto" "github.com/onflow/go-ethereum/rpc" - errs "github.com/onflow/flow-evm-gateway/api/errors" "github.com/onflow/flow-evm-gateway/config" ) @@ -47,7 +48,17 @@ func (w *WalletAPI) Sign( addr common.Address, data hexutil.Bytes, ) (hexutil.Bytes, error) { - return nil, errs.ErrNotSupported + // Transform the given message to the following format: + // keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) + hash := accounts.TextHash(data) + // Sign the hash using plain ECDSA operations + signature, err := crypto.Sign(hash, w.config.WalletKey) + if err == nil { + // Transform V from 0/1 to 27/28 according to the yellow paper + signature[64] += 27 + } + + return signature, err } // SignTransaction will sign the given transaction with the from account. @@ -57,12 +68,25 @@ func (w *WalletAPI) SignTransaction( ctx context.Context, args TransactionArgs, ) (*SignTransactionResult, error) { + if args.Gas == nil { + return nil, errors.New("gas not specified") + } + if args.GasPrice == nil && (args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil) { + return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") + } + + accounts, err := w.Accounts() + if err != nil { + return nil, err + } + from := accounts[0] + nonce := uint64(0) if args.Nonce != nil { nonce = uint64(*args.Nonce) } else { num := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) - n, err := w.net.GetTransactionCount(ctx, *args.From, &num) + n, err := w.net.GetTransactionCount(ctx, from, &num) if err != nil { return nil, err } From c2e901679a0a858a24dadf48cc9845d0e1b81e07 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 8 Jul 2024 17:46:23 +0300 Subject: [PATCH 8/8] Add wallet-api-key flag for start-local Make recipe --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 40cd486c8..aa51e6fa6 100644 --- a/Makefile +++ b/Makefile @@ -44,4 +44,4 @@ start: .PHONY: start-local start-local: rm -rf db/ - go run cmd/main/main.go --flow-network-id=flow-emulator --coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E --coa-address=f8d6e0586b0a20c7 --coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 --coa-resource-create=true --gas-price=0 --log-writer=console + go run cmd/main/main.go --flow-network-id=flow-emulator --coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E --coa-address=f8d6e0586b0a20c7 --coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 --wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 --coa-resource-create=true --gas-price=0 --log-writer=console