Open kelvinolumeni opened 9 months ago
from web3 import Web3
alchemy_url = "https://eth-mainnet.g.alchemy.com/v2/K65KESvPum3ui73Jk6wOxxREAh8a2buu" w3 = Web3(Web3.HTTPProvider(alchemy_url))
print(w3.isConnected())
latest_block = w3.eth.get_block("latest") print(latest_block) package main
import ( "context" "fmt" "log"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" )
func main() { client, err := ethclient.Dial("https://eth-mainnet.g.alchemy.com/v2/K65KESvPum3ui73Jk6wOxxREAh8a2buu") if err != nil { log.Fatal(err) }
// Get the latest known block block, err := client.BlockByNumber(context.Background(), nil) if err != nil { log.Fatal(err) } fmt.Println("Latest block:", block.Number().Uint64())
}
I want to work on this
Setup
from web3 import Web3
alchemy_url = "https://eth-mainnet.g.alchemy.com/v2/K65KESvPum3ui73Jk6wOxxREAh8a2buu" w3 = Web3(Web3.HTTPProvider(alchemy_url))
Print if web3 is successfully connected
print(w3.isConnected())
Get the latest block number
latest_block = w3.eth.get_block("latest") print(latest_block) package main
import ( "context" "fmt" "log"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" )
func main() { client, err := ethclient.Dial("https://eth-mainnet.g.alchemy.com/v2/K65KESvPum3ui73Jk6wOxxREAh8a2buu") if err != nil { log.Fatal(err) }
}