### Verify installation with CMake Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/crypto/secp256k1/libsecp256k1/doc/release-process.md Tests the installation process and compiles an example using CMake. ```shell dir=$(mktemp -d) build=$(mktemp -d) cmake -B $build -DCMAKE_INSTALL_PREFIX=$dir && cmake --build $build && cmake --install $build && ls -RlAh $dir gcc -o ecdsa examples/ecdsa.c -I $dir/include -L $dir/lib*/ -l secp256k1 -Wl,-rpath,"$dir/lib",-rpath,"$dir/lib64" && ./ecdsa ``` -------------------------------- ### Verify installation with autotools Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/crypto/secp256k1/libsecp256k1/doc/release-process.md Tests the installation process and compiles an example using autotools. ```shell dir=$(mktemp -d) ./autogen.sh && ./configure --prefix=$dir && make clean && make install && ls -RlAh $dir gcc -o ecdsa examples/ecdsa.c $(PKG_CONFIG_PATH=$dir/lib/pkgconfig pkg-config --cflags --libs libsecp256k1) -Wl,-rpath,"$dir/lib" && ./ecdsa ``` -------------------------------- ### Configure Installation Logic Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/crypto/secp256k1/libsecp256k1/src/CMakeLists.txt Handles installation of the library, headers, and CMake package configuration files. ```cmake if(SECP256K1_INSTALL) install(TARGETS secp256k1 EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) set(${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1.h" "${PROJECT_SOURCE_DIR}/include/secp256k1_preallocated.h" ) if(SECP256K1_ENABLE_MODULE_ECDH) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_ecdh.h") endif() if(SECP256K1_ENABLE_MODULE_RECOVERY) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_recovery.h") endif() if(SECP256K1_ENABLE_MODULE_EXTRAKEYS) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_extrakeys.h") endif() if(SECP256K1_ENABLE_MODULE_SCHNORRSIG) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_schnorrsig.h") endif() if(SECP256K1_ENABLE_MODULE_MUSIG) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_musig.h") endif() if(SECP256K1_ENABLE_MODULE_ELLSWIFT) list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_ellswift.h") endif() install(FILES ${${PROJECT_NAME}_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(EXPORT ${PROJECT_NAME}-targets FILE ${PROJECT_NAME}-targets.cmake NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) include(CMakePackageConfigHelpers) configure_package_config_file( ${PROJECT_SOURCE_DIR}/cmake/config.cmake.in ${PROJECT_NAME}-config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} NO_SET_AND_CHECK_MACRO ) write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY SameMinorVersion ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake ``` -------------------------------- ### Install Ethkit CLI Source: https://github.com/0xsequence/ethkit/blob/master/cmd/ethkit/README.md Use the go get command to install the ethkit CLI tool. ```shell go get github.com/0xsequence/ethkit/cmd/ethkit ``` -------------------------------- ### Start Geth Console for Mainnet Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Starts Geth in snap sync mode and launches the interactive JavaScript console for interacting with the Ethereum main network. Use this for general interaction and contract deployment. ```shell $ geth console ``` -------------------------------- ### Install Ethkit CLI Source: https://github.com/0xsequence/ethkit/blob/master/README.md Install the latest version of the Ethkit CLI using the Go toolchain. ```bash go install github.com/0xsequence/ethkit/cmd/ethkit@latest ``` -------------------------------- ### Docker Quick Start for Geth Node Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Runs a Geth node using Docker, starting in snap-sync mode with a 1GB DB memory allowance. It sets up a persistent volume for blockchain data and maps default RPC and P2P ports. ```shell docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \ -p 8545:8545 -p 30303:30303 \ ethereum/client-go ``` -------------------------------- ### Start Geth Console for Görli Testnet Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Starts Geth and connects to the Görli test network, using a separate data directory and different network configurations. Ideal for development and testing without real funds. ```shell $ geth --goerli console ``` -------------------------------- ### Initialize and Run ethmonitor and ethreceipts Listener Source: https://context7.com/0xsequence/ethkit/llms.txt Sets up the RPC provider, logger, and monitor. Initializes the receipts listener with finality options and starts their respective run loops. Ensure the monitor is started with `WithLogs: true` for the receipts listener to function. ```go package main import ( "context" "fmt" "log/slog" "os" "time" "github.com/0xsequence/ethkit/ethmonitor" "github.com/0xsequence/ethkit/ethreceipts" "github.com/0xsequence/ethkit/ethrpc" "github.com/0xsequence/ethkit/go-ethereum/common" ) func main() { provider, _ := ethrpc.NewProvider("https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY") logger := slog.New(slog.NewTextHandler(os.Stdout, nil)) // Monitor with logs enabled (required for receipts listener) monitor, _ := ethmonitor.NewMonitor(provider, ethmonitor.Options{ Logger: logger, PollingInterval: 2 * time.Second, WithLogs: true, BlockRetentionLimit: 100, }) ctx := context.Background() go monitor.Run(ctx) time.Sleep(3 * time.Second) // Create receipts listener listener, err := ethreceipts.NewReceiptsListener(logger, provider, monitor, ethreceipts.Options{ NumBlocksToFinality: 12, // Wait 12 blocks for finality }) if err != nil { panic(err) } go listener.Run(ctx) time.Sleep(2 * time.Second) // Fetch a specific transaction receipt txHash := common.HexToHash("0x...") receipt, err := listener.FetchTransactionReceipt(ctx, txHash, 100) // max wait 100 blocks if err != nil { fmt.Println("Receipt not found:", err) } else { fmt.Println("Transaction status:", receipt.Status()) fmt.Println("Gas used:", receipt.GasUsed()) } // Fetch with finality confirmation receipt, waitFinality, err := listener.FetchTransactionReceiptWithFinality(ctx, txHash, 50) if err != nil { panic(err) } fmt.Println("Receipt found, waiting for finality...") finalReceipt, err := waitFinality(ctx) if err != nil { panic(err) } fmt.Println("Transaction finalized at block:", finalReceipt.BlockNumber()) // Subscribe with filters transferTopic := common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") sub := listener.Subscribe( ethreceipts.FilterTxnHash(txHash).Finalize(true), ethreceipts.FilterLog(func(log *types.Log) bool { return log.Address == usdtAddress && len(log.Topics) > 0 && log.Topics[0] == transferTopic }), ) defer sub.Unsubscribe() for { select { case receipt := <-sub.TransactionReceipt(): if receipt.Reorged { fmt.Println("Transaction was reorged!") continue } if receipt.Final { fmt.Println("Transaction finalized!") } fmt.Printf("Receipt: status=%d, block=%s\n", receipt.Status(), receipt.BlockNumber()) case <-sub.Done(): return } } } ``` -------------------------------- ### Generate and run a bootnode Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Use these commands to create a private key and start a bootnode for peer discovery. ```shell $ bootnode --genkey=boot.key $ bootnode --nodekey=boot.key ``` -------------------------------- ### Start a member node Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Connect a new node to the network by specifying the data directory and the bootnode's enode URL. ```shell $ geth --datadir=path/to/custom/data/folder --bootnodes= ``` -------------------------------- ### Build All Utilities Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Use this command to compile the entire suite of Go Ethereum utilities. This requires Go (version 1.21 or later) and a C compiler to be installed. ```shell make all ``` -------------------------------- ### Build Geth Executable Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Use this command to compile the main 'geth' executable. Ensure Go (version 1.21 or later) and a C compiler are installed. ```shell make geth ``` -------------------------------- ### Cross-Compile with CMake Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/crypto/secp256k1/libsecp256k1/README.md Examples for cross-compiling to Windows or Android using toolchain files. ```bash $ cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/x86_64-w64-mingw32.toolchain.cmake ``` ```bash $ cmake -B build -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=28 ``` -------------------------------- ### Initialize Geth Node with Genesis State Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Initializes a Geth node using a specified genesis state file. This must be done before starting the node. ```shell $ geth init path/to/genesis.json ``` -------------------------------- ### Pre-funding Accounts in Genesis State Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Example of how to pre-fund specific accounts with balances in the genesis state configuration. ```json "alloc": { "0x0000000000000000000000000000000000000001": { "balance": "111111111" }, "0x0000000000000000000000000000000000000002": { "balance": "222222222" } } ``` -------------------------------- ### Run Ethfinalizer Loop Source: https://github.com/0xsequence/ethkit/blob/master/ethfinalizer/README.md Start the blocking run loop for the finalizer. This must be called for the finalizer to operate. ```go err := finalizer.Run(ctx) ``` -------------------------------- ### Start a private miner Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Configure a geth instance to mine blocks on a single thread with a specified etherbase address. ```shell $ geth --mine --miner.threads=1 --miner.etherbase=0x0000000000000000000000000000000000000000 ``` -------------------------------- ### Manage Ethereum Wallets with Ethkit Source: https://context7.com/0xsequence/ethkit/llms.txt Create, restore, and manage Ethereum wallets using BIP-39 mnemonics and private keys. Connect to a provider to perform blockchain operations like getting balances, signing messages, and deriving multiple accounts. ```go package main import ( "context" "fmt" "math/big" "github.com/0xsequence/ethkit/ethwallet" "github.com/0xsequence/ethkit/ethrpc" ) func main() { // Create a new random wallet with 24-word mnemonic wallet, err := ethwallet.NewWalletFromRandomEntropy(ethwallet.WalletOptions{ DerivationPath: "m/44'/60'/0'/0/0", RandomWalletEntropyBitSize: ethwallet.EntropyBitSize24WordMnemonic, // 256 bits }) if err != nil { panic(err) } fmt.Println("Address:", wallet.Address().Hex()) fmt.Println("Mnemonic:", wallet.HDNode().Mnemonic()) // Restore wallet from mnemonic mnemonic := "test test test test test test test test test test test junk" restoredWallet, err := ethwallet.NewWalletFromMnemonic(mnemonic, "m/44'/60'/0'/0/0") if err != nil { panic(err) } fmt.Println("Restored address:", restoredWallet.Address().Hex()) // Create wallet from private key privateKeyHex := "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" pkWallet, err := ethwallet.NewWalletFromPrivateKey(privateKeyHex[2:]) // without 0x prefix if err != nil { panic(err) } fmt.Println("PK Wallet address:", pkWallet.Address().Hex()) // Connect wallet to provider for blockchain operations provider, _ := ethrpc.NewProvider("https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY") wallet.SetProvider(provider) // Get balance balance, err := wallet.GetBalance(context.Background()) if err != nil { panic(err) } fmt.Println("Balance:", balance) // Sign a message (EIP-191) message := []byte("Hello Ethereum!") signature, err := wallet.SignMessage(message) if err != nil { panic(err) } fmt.Printf("Signature: 0x%x\n", signature) // Verify signature valid, err := wallet.IsValidSignature(message, signature) fmt.Println("Valid signature:", valid) // Derive multiple accounts from the same mnemonic account1, addr1, _ := wallet.DeriveFromAccountIndex(1) account2, addr2, _ := wallet.DeriveFromPath("m/44'/60'/0'/0/2") fmt.Println("Account 1:", addr1.Hex()) fmt.Println("Account 2:", addr2.Hex()) _, _ = account1, account2 } ``` -------------------------------- ### Configure secp256k1 Include Directories Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/crypto/secp256k1/libsecp256k1/src/CMakeLists.txt Configures interface include directories for the secp256k1 library, making its headers available to parent projects during build and installation. ```cmake target_include_directories(secp256k1 INTERFACE # Add the include path for parent projects so that they don't have to manually add it. $>:${PROJECT_SOURCE_DIR}/include> $ ) ``` -------------------------------- ### GET /G Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/structs.go.txt Retrieves an array of structs from the contract. ```APIDOC ## GET /G ### Description Retrieves an array of structs (A) containing bytes32 values. ### Method GET ### Endpoint /G ### Response #### Success Response (200) - **a** (array of Struct0) - Array of structs containing bytes32 B ``` -------------------------------- ### GET /events/ProposalAdded Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/dao.go.txt Unpacks the ProposalAdded event data from a blockchain log. ```APIDOC ## GET /events/ProposalAdded ### Description Unpacks the event data emitted by the contract for the ProposalAdded event. ### Response #### Success Response (200) - **proposalID** (uint256) - The ID of the proposal. - **recipient** (address) - The recipient address. - **amount** (uint256) - The amount associated with the proposal. - **description** (string) - The description of the proposal. ``` -------------------------------- ### GET /events/MembershipChanged Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/dao.go.txt Unpacks the MembershipChanged event data from a blockchain log. ```APIDOC ## GET /events/MembershipChanged ### Description Unpacks the event data emitted by the contract for the MembershipChanged event. ### Response #### Success Response (200) - **member** (address) - The address of the member. - **isMember** (bool) - The membership status. ``` -------------------------------- ### GET /events/ChangeOfRules Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/dao.go.txt Unpacks the ChangeOfRules event data from a blockchain log. ```APIDOC ## GET /events/ChangeOfRules ### Description Unpacks the event data emitted by the contract for the ChangeOfRules event. ### Response #### Success Response (200) - **minimumQuorum** (uint256) - The new minimum quorum. - **debatingPeriodInMinutes** (uint256) - The new debating period. - **majorityMargin** (int256) - The new majority margin. ``` -------------------------------- ### Create Contract Instance Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/tupler.go.txt Wraps a deployed contract address with the necessary backend to enable contract interactions. ```go // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Tupler) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } ``` -------------------------------- ### Balance Command Usage Source: https://github.com/0xsequence/ethkit/blob/master/README.md View the help documentation and flags for querying account balances via RPC. ```bash Usage: ethkit balance [account] [flags] Flags: -B, --block string The block height to query at (default "latest") -e, --ether Format the balance in ether -h, --help help for balance -r, --rpc-url string The RPC endpoint to the blockchain node to interact with ``` -------------------------------- ### GET _myVar Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt Retrieves the value of the _myVar state variable from the contract. ```APIDOC ## GET _myVar ### Description Retrieves the uint256 value stored in the _myVar variable. ### Method GET ### Response #### Success Response (200) - **value** (uint256) - The current value of _myVar. ``` -------------------------------- ### GET MyVar Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt Retrieves the value of the MyVar state variable from the contract. ```APIDOC ## GET MyVar ### Description Retrieves the uint256 value stored in the MyVar variable. ### Method GET ### Response #### Success Response (200) - **value** (uint256) - The current value of MyVar. ``` -------------------------------- ### Create EthRPC Provider and Fetch Data Source: https://context7.com/0xsequence/ethkit/llms.txt Demonstrates how to create a new EthRPC provider with streaming enabled and fetch basic chain information like chain ID, block number, and account balance. Ensure you replace 'YOUR_API_KEY' with your actual API key. ```go package main import ( "context" "fmt" "math/big" "github.com/0xsequence/ethkit/ethrpc" "github.com/0xsequence/ethkit/go-ethereum" "github.com/0xsequence/ethkit/go-ethereum/common" ) func main() { // Create provider with options provider, err := ethrpc.NewProvider( "https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY", ethrpc.WithStreaming("wss://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY"), ) if err != nil { panic(err) } ctx := context.Background() // Get chain ID chainID, _ := provider.ChainID(ctx) fmt.Println("Chain ID:", chainID) // Get latest block number blockNum, _ := provider.BlockNumber(ctx) fmt.Println("Block number:", blockNum) // Get account balance address := common.HexToAddress("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045") // vitalik.eth balance, _ := provider.BalanceAt(ctx, address, nil) fmt.Println("Balance (wei):", balance) // Get block by number block, _ := provider.BlockByNumber(ctx, big.NewInt(int64(blockNum))) fmt.Println("Block hash:", block.Hash().Hex()) fmt.Println("Transactions:", len(block.Transactions())) // Get transaction by hash txHash := common.HexToHash("0x...") tx, isPending, _ := provider.TransactionByHash(ctx, txHash) fmt.Println("Is pending:", isPending) fmt.Println("Gas price:", tx.GasPrice()) // Get transaction receipt receipt, _ := provider.TransactionReceipt(ctx, txHash) fmt.Println("Status:", receipt.Status) // 1 = success, 0 = failed fmt.Println("Gas used:", receipt.GasUsed) // Filter logs query := ethereum.FilterQuery{ FromBlock: big.NewInt(int64(blockNum - 100)), ToBlock: big.NewInt(int64(blockNum)), Addresses: []common.Address{common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7")}, // USDT } logs, _ := provider.FilterLogs(ctx, query) fmt.Println("Found logs:", len(logs)) // Batch requests - execute multiple calls in parallel var balance1, balance2 *big.Int var blockNumber uint64 _, err = provider.Do(ctx, ethrpc.BalanceAt(address, nil).Into(&balance1), ethrpc.BalanceAt(common.HexToAddress("0x..."), nil).Into(&balance2), ethrpc.BlockNumber().Into(&blockNumber), ) if err != nil { panic(err) } // Contract query helper result, _ := provider.ContractQuery(ctx, "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT contract "balanceOf(address)", // method signature "uint256", // return type []string{address.Hex()}, ) fmt.Println("USDT balance:", result) // Suggest gas price gasPrice, _ := provider.SuggestGasPrice(ctx) fmt.Println("Gas price:", gasPrice) // Subscribe to new blocks (requires WebSocket) if provider.IsStreamingEnabled() { headers := make(chan *types.Header) sub, _ := provider.SubscribeNewHeads(ctx, headers) defer sub.Unsubscribe() for header := range headers { fmt.Println("New block:", header.Number) } } } ``` -------------------------------- ### GET getRequest Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/nameconflict.go.txt Methods to pack and unpack the getRequest contract method call. ```APIDOC ## GET getRequest ### Description Methods to pack the request for getRequest and unpack the returned data. ### Method GET ### Response #### Success Response (200) - **data** (Oraclerequest) - The unpacked result from the getRequest call. ``` -------------------------------- ### Initialize OutputChecker Binding Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/outputchecker.go.txt Creates a new instance of the OutputChecker Go binding. Panics if the ABI is invalid. Requires the ethkit/go-ethereum/accounts/abi package. ```go // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. package bindtests import ( "bytes" "errors" "math/big" "github.com/0xsequence/ethkit/go-ethereum/accounts/abi" "github.com/0xsequence/ethkit/go-ethereum/accounts/abi/bind/v2" "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/core/types" ) // Reference imports to suppress errors if they are not otherwise used. var ( _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType ) // OutputCheckerMetaData contains all meta data concerning the OutputChecker contract. var OutputCheckerMetaData = bind.MetaData{ ABI: "[{"type":"function","name":"noOutput","constant":true,"inputs":[],"outputs":[]},{"type":"function","name":"namedOutput","constant":true,"inputs":[],"outputs":[{"name":"str","type":"string"}]},{"type":"function","name":"anonOutput","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"}]},{"type":"function","name":"namedOutputs","constant":true,"inputs":[],"outputs":[{"name":"str1","type":"string"},{"name":"str2","type":"string"}]},{"type":"function","name":"collidingOutputs","constant":true,"inputs":[],"outputs":[{"name":"str","type":"string"},{"name":"Str","type":"string"}]},{"type":"function","name":"anonOutputs","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"},{"name":"","type":"string"}]},{"type":"function","name":"mixedOutputs","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"},{"name":"str","type":"string"}]}]", ID: "cc1d4e235801a590b506d5130b0cca90a1", } // OutputChecker is an auto generated Go binding around an Ethereum contract. type OutputChecker struct { abi abi.ABI } // NewOutputChecker creates a new instance of OutputChecker. func NewOutputChecker() *OutputChecker { parsed, err := OutputCheckerMetaData.ParseABI() if err != nil { panic(errors.New("invalid ABI: " + err.Error())) } return &OutputChecker{abi: *parsed} } ``` -------------------------------- ### GET tuple() Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/tupler.go.txt Retrieves a tuple containing a string, an int256, and a bytes32 value from the contract. ```APIDOC ## GET tuple() ### Description Calls the contract method 'tuple' to retrieve a structured set of data. ### Method GET ### Response #### Success Response (200) - **a** (string) - The string component of the tuple - **b** (int256) - The integer component of the tuple - **c** (bytes32) - The bytes32 component of the tuple #### Response Example { "a": "example string", "b": 12345, "c": "0x0000000000000000000000000000000000000000000000000000000000000000" } ``` -------------------------------- ### GET /F Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/structs.go.txt Retrieves an array of structs, an array of uint256, and an array of booleans from the contract. ```APIDOC ## GET /F ### Description Retrieves the combined data structure containing an array of structs (A), an array of uint256 (C), and an array of booleans (D). ### Method GET ### Endpoint /F ### Response #### Success Response (200) - **a** (array of Struct0) - Array of structs containing bytes32 B - **c** (array of uint256) - Array of unsigned integers - **d** (array of bool) - Array of boolean values ``` -------------------------------- ### Configure Geth with a TOML File Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/README.md Launches Geth using a specified TOML configuration file instead of command-line flags. This is useful for managing complex configurations. ```shell $ geth --config /path/to/your_config.toml ``` -------------------------------- ### Initialize and Interact with Contract Bindings Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/getter.go.txt Use these methods to instantiate a contract wrapper and pack/unpack data for the 'getter' function. ```go // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. package bindtests import ( "bytes" "errors" "math/big" "github.com/0xsequence/ethkit/go-ethereum/accounts/abi" "github.com/0xsequence/ethkit/go-ethereum/accounts/abi/bind/v2" "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/core/types" ) // Reference imports to suppress errors if they are not otherwise used. var ( _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType ) // GetterMetaData contains all meta data concerning the Getter contract. var GetterMetaData = bind.MetaData{ ABI: "[{\"constant\":true,\"inputs\":[],\"name\":\"getter\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"int256\"},{\"name\":\"\",\"type\":\"bytes32\"}],\"type\":\"function\"}]", ID: "e23a74c8979fe93c9fff15e4f51535ad54", Bin: "0x606060405260dc8060106000396000f3606060405260e060020a6000350463993a04b78114601a575b005b600060605260c0604052600260809081527f486900000000000000000000000000000000000000000000000000000000000060a05260017fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060e0829052610100819052606060c0908152600261012081905281906101409060a09080838184600060046012f1505081517fffff000000000000000000000000000000000000000000000000000000000000169091525050604051610160819003945092505050f3", } // Getter is an auto generated Go binding around an Ethereum contract. type Getter struct { abi abi.ABI } // NewGetter creates a new instance of Getter. func NewGetter() *Getter { parsed, err := GetterMetaData.ParseABI() if err != nil { panic(errors.New("invalid ABI: " + err.Error())) } return &Getter{abi: *parsed} } // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Getter) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } // PackGetter is the Go binding used to pack the parameters required for calling // the contract method with ID 0x993a04b7. // // Solidity: function getter() returns(string, int256, bytes32) func (getter *Getter) PackGetter() []byte { enc, err := getter.abi.Pack("getter") if err != nil { panic(err) } return enc } // GetterOutput serves as a container for the return parameters of contract // method Getter. type GetterOutput struct { Arg0 string Arg1 *big.Int Arg2 [32]byte } // UnpackGetter is the Go binding that unpacks the parameters returned // from invoking the contract method with ID 0x993a04b7. // // Solidity: function getter() returns(string, int256, bytes32) func (getter *Getter) UnpackGetter(data []byte) (GetterOutput, error) { out, err := getter.abi.Unpack("getter", data) outstruct := new(GetterOutput) if err != nil { return *outstruct, err } outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string) outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) outstruct.Arg2 = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte) return *outstruct, err } ``` -------------------------------- ### Create Ethfinalizer Instance Source: https://github.com/0xsequence/ethkit/blob/master/ethfinalizer/README.md Initialize a finalizer for a specific wallet and chain. Configure polling intervals, timeouts, retry delays, and fee margins. ```go finalizer, err := ethfinalizer.NewFinalizer(ethfinalizer.FinalizerOptions[struct{}]{ Wallet: wallet, Chain: chain, Mempool: mempool, Logger: nil, PollInterval: 5 * time.Second, // period between chain state checks PollTimeout: 4 * time.Second, // time limit for operations while checking chain state RetryDelay: 24 * time.Second, // minimum time to wait before retrying a transaction FeeMargin: 25, // percentage added on top of the estimated gas price PriceBump: 15, // go-ethereum requires at least 10% by default }) ``` -------------------------------- ### GET /api/users/{id} Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/outputchecker.go.txt Retrieves details for a specific user by their ID. The user ID is a path parameter. ```APIDOC ## GET /api/users/{id} ### Description This endpoint retrieves the details of a specific user identified by their unique ID. The ID is provided as a path parameter. ### Method GET ### Endpoint /api/users/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the user to retrieve. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the user. - **username** (string) - The username of the user. - **email** (string) - The email address of the user. #### Response Example ```json { "id": "user-12345", "username": "johndoe", "email": "john.doe@example.com" } ``` #### Error Response (404) - **message** (string) - Indicates that the user with the specified ID was not found. #### Error Response Example ```json { "message": "User not found" } ``` ``` -------------------------------- ### Initialize Contract Binding Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/empty.go.txt The generated code provides a metadata object and a constructor to instantiate the contract binding. Use the Instance method to bind the contract to a specific address on a backend. ```go // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. package bindtests import ( "bytes" "errors" "math/big" "github.com/0xsequence/ethkit/go-ethereum/accounts/abi" "github.com/0xsequence/ethkit/go-ethereum/accounts/abi/bind/v2" "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/core/types" ) // Reference imports to suppress errors if they are not otherwise used. var ( _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType ) // EmptyMetaData contains all meta data concerning the Empty contract. var EmptyMetaData = bind.MetaData{ ABI: "[]", ID: "c4ce3210982aa6fc94dabe46dc1dbf454d", Bin: "0x606060405260068060106000396000f3606060405200", } // Empty is an auto generated Go binding around an Ethereum contract. type Empty struct { abi abi.ABI } // NewEmpty creates a new instance of Empty. func NewEmpty() *Empty { parsed, err := EmptyMetaData.ParseABI() if err != nil { panic(errors.New("invalid ABI: " + err.Error())) } return &Empty{abi: *parsed} } // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Empty) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } ``` -------------------------------- ### Initialize Contract Bindings Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/eventchecker.go.txt Contains the generated ABI metadata and the constructor for the EventChecker contract binding. ```go // EventCheckerMetaData contains all meta data concerning the EventChecker contract. var EventCheckerMetaData = bind.MetaData{ ABI: "[{\"type\":\"event\",\"name\":\"empty\",\"inputs\":[]},{\"type\":\"event\",\"name\":\"indexed\",\"inputs\":[{\"name\":\"addr\",\"type\":\"address\",\"indexed\":true},{\"name\":\"num\",\"type\":\"int256\",\"indexed\":true}]},{\"type\":\"event\",\"name\":\"mixed\",\"inputs\":[{\"name\":\"addr\",\"type\":\"address\",\"indexed\":true},{\"name\":\"num\",\"type\":\"int256\"}]},{\"type\":\"event\",\"name\":\"anonymous\",\"anonymous\":true,\"inputs\":[]},{\"type\":\"event\",\"name\":\"dynamic\",\"inputs\":[{\"name\":\"idxStr\",\"type\":\"string\",\"indexed\":true},{\"name\":\"idxDat\",\"type\":\"bytes\",\"indexed\":true},{\"name\":\"str\",\"type\":\"string\"},{\"name\":\"dat\",\"type\":\"bytes\"}]},{\"type\":\"event\",\"name\":\"unnamed\",\"inputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":true},{\"name\":\"\",\"type\":\"uint256\",\"indexed\":true}]}]", ID: "253d421f98e29b25315bde79c1251ab27c", } // EventChecker is an auto generated Go binding around an Ethereum contract. type EventChecker struct { abi abi.ABI } // NewEventChecker creates a new instance of EventChecker. func NewEventChecker() *EventChecker { parsed, err := EventCheckerMetaData.ParseABI() if err != nil { panic(errors.New("invalid ABI: " + err.Error())) } return &EventChecker{abi: *parsed} } ``` -------------------------------- ### Create Deployed Contract Instance Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/nameconflict.go.txt Creates a wrapper for a deployed contract instance at a given address, enabling interaction with contract methods. ```go // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *NameConflict) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } ``` -------------------------------- ### Create New DAO Instance Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/dao.go.txt Instantiates a new DAO object, parsing the ABI. Panics if the ABI is invalid. ```Go func NewDAO() *DAO { parsed, err := DAOMetaData.ParseABI() if err != nil { panic(errors.New("invalid ABI: " + err.Error())) } return &DAO{abi: *parsed} } ``` -------------------------------- ### Get Contract Event Name in Go Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/overload.go.txt Returns the predefined event name for OverloadBar0. This is typically used for event identification. ```go func (OverloadBar0) ContractEventName() string { return OverloadBar0EventName } ``` -------------------------------- ### Wallet Command Usage Source: https://github.com/0xsequence/ethkit/blob/master/README.md View the help documentation and flags for the wallet management command. ```bash Usage: ethkit wallet [flags] Flags: -h, --help help for wallet --import-mnemonic import a secret mnemonic to a new keyfile --keyfile string wallet key file path --new create a new wallet and save it to the keyfile --print-account print wallet account address from keyfile (default) (default true) --print-mnemonic print wallet secret mnemonic from keyfile (danger!) ``` -------------------------------- ### Create Deployed Contract Instance Wrapper Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/outputchecker.go.txt Generates a wrapper for a deployed contract instance at a given address. This is used for calling contract methods like Call, Transact, etc. Requires a bind.ContractBackend and the contract's address. ```go // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *OutputChecker) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } ``` -------------------------------- ### Create DAO Contract Instance Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/dao.go.txt Creates a wrapper for a deployed contract instance at a given address. Use this for calling contract methods. ```Go func (c *DAO) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } ``` -------------------------------- ### Pack Constructor Parameters Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/accounts/abi/abigen/testdata/v2/token.go.txt Encodes the initial supply, name, decimals, and symbol for contract deployment. ```go func (token *Token) PackConstructor(initialSupply *big.Int, tokenName string, decimalUnits uint8, tokenSymbol string) []byte { enc, err := token.abi.Pack("", initialSupply, tokenName, decimalUnits, tokenSymbol) if err != nil { panic(err) } return enc } ``` -------------------------------- ### C89 Block Declaration Example Source: https://github.com/0xsequence/ethkit/blob/master/go-ethereum/crypto/secp256k1/libsecp256k1/CONTRIBUTING.md Demonstrates C89 style for variable declarations within blocks, showing how to open new blocks to declare variables in the middle of a function. ```c void secp256k_foo(void) { unsigned int x; /* declaration */ int y = 2*x; /* declaration */ x = 17; /* statement */ { int a, b; /* declaration */ a = x + y; /* statement */ secp256k_bar(x, &b); /* statement */ } } ``` -------------------------------- ### Ethkit CLI Help Source: https://github.com/0xsequence/ethkit/blob/master/cmd/ethkit/README.md Display the help message for the ethkit CLI to see available commands and flags. ```shell $ ethkit --help ``` ```shell ethkit - Ethereum dev toolkit Usage: ethkit [command] Available Commands: abigen generate contract client code from a truffle artifacts file artifacts print the contract abi or bytecode from a truffle artifacts file help Help about any command version print the version number wallet encrypted wallet creation+management Flags: -h, --help help for ethkit Use "ethkit [command] --help" for more information about a command ```