GoChain CLI is a basic blockchain implementation in Go. This application allows interactions with the Ethereum network, including wallet generation, transaction creation, and checking balances and network data.
- Clone the repository:
git clone https://github.com/your-username/cli-gochain.git cd cli-gochain
- Install dependencies:
go mod tidy
- Build the application:
go build -o gochain
generate-wallet
: Generates a new Ethereum wallet and saves it in memory.Output:./gochain generate-wallet
PublicKey: 0x123...abc PrivateKey: 0xdef...456
get-wallets-inmemory
: Displays all Ethereum wallets currently stored in memory.Output:./gochain get-wallets-inmemory
Ethereum wallets in memory: [0x123...abc, 0xdef...456]
set-network-node <network> <nodeUrl>
: Sets the network node for the Ethereum client.Output:./gochain set-network-node mainnet https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID
Network mainnet successfully added
get-blocknumber <network>
: Gets the current block number of a specified network.Output:./gochain get-blocknumber mainnet
Current blockNumber: 13245678
create-transaction <network> <from> <to> <amount>
: Creates an Ethereum transaction.Output:./gochain create-transaction mainnet 0x123...abc 0x456...def 1000000000000000000
Note: TheTransaction created successfully with hash: 0xabc123...789
from
address must be one of the addresses generated by thegenerate-wallet
command.get-balance <network> <address>
: Retrieves the balance of an Ethereum address.Output:./gochain get-balance mainnet 0x123...abc
Balance: 1.234567890123456789 ETH
get-transaction-receipt <network> <txHash>
: Gets the receipt of a specific transaction.Output:./gochain get-transaction-receipt mainnet 0xabc123...789
Transaction receipt: {Status: 1, BlockNumber: 13245678, GasUsed: 21000, ...}
main.go
: The main file that defines the CLI usingcobra.Command
.database/memory.go
: Responsible for in-memory storage of data such as wallets and network settings.evm
: Module that interacts directly with the Ethereum Virtual Machine (EVM), including wallet creation, transactions, and network data retrieval.
Cobra
: A library for creating beautiful command-line interfaces in Go.Go-Ethereum
: A Go implementation of the Ethereum protocol.
This project is licensed under the MIT License.