kelvinolumeni / codesandbox-template-nuxt

NuxtJS template for CodeSandbox Projects
Apache License 2.0
0 stars 0 forks source link

Python-sdk #2

Open kelvinolumeni opened 9 months ago

kelvinolumeni commented 9 months ago

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) }

// 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())

}

siddhant-suri commented 9 months ago

I want to work on this