// Init initializes the client connecting to the ethereum node url.
// A secret password is optional. "secret" is needed for Infura's v3 API.
Init initializes the client connecting to the ethereum node url.
A secret password is optional. "secret" is needed for Infura's v3 API.
// Init initializes the client connecting to the ethereum node url . // A secret password is optional . " secret " is needed for Infura ' s v3 API .
func Init(nodeUrl, secret string) *EthCli {
	if secret == "" {
		return &EthCli{jsonrpc2.NewHTTPClient(nodeUrl)}
	}
	return &EthCli{jsonrpc2.NewCustomHTTPClient(nodeUrl,
		jsonrpc2.DoerFunc(func(req *http.Request) (*http.Response, error) {
			client := &http.Client{}
			req.Header.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(secret)))
			return client.Do(req)
		}))}
}
func Init ( nodeUrl , secret string ) * EthCli { if secret == " " { return & EthCli { jsonrpc2 . NewHTTPClient ( nodeUrl ) } } return & EthCli { jsonrpc2 . NewCustomHTTPClient ( nodeUrl , jsonrpc2 . DoerFunc ( func ( req * http . Request ) ( * http . Response , error ) { client := & http . Client { } req . Header . Add ( " " , " " + base64 . StdEncoding . EncodeToString ( [ ] byte ( secret ) ) ) return client . Do ( req ) } ) ) } }
Init initializes the client connecting to the ethereum node url.
Init initializes the client connecting to the ethereum node url .
// Setup custom HTTP client. // Modify request as needed.