2

I've tried looking for API's to download that latest block but I can't find anything for BSC. So far the best I can do is browsing to BSCscan.com/blocks, and maybe using curl but I'm sure someone knows a much better way.

7
  • What do you mean with download? Do you mean fork?
    – Emrah
    Commented May 19, 2022 at 21:54
  • 1
    So you want to run full node? docs.binance.org/smart-chain/developer/fullnode.html
    – Emrah
    Commented May 19, 2022 at 21:58
  • 2
    There is no such a thing just getting a single block. You can check the transactions of most recent block by connecting to provider (such as Infura) and using command getBlock. web3py.readthedocs.io/en/stable/…
    – Emrah
    Commented May 19, 2022 at 22:10
  • 1
    This is exactly what I'm after! Except BSC instead of etherium. I'll search a little more! Thanks!
    – Adjam
    Commented May 19, 2022 at 22:13
  • 1
    Please make sure to answer your question so the future people can also know, once you find the solution! I am curious too :) Commented May 20, 2022 at 3:34

1 Answer 1

1

This solution worked for me:

from web3 import Web3
from web3.middleware import geth_poa_middleware

w3 = Web3(Web3.HTTPProvider("https://bsc-dataseed.binance.org/"))
w3.middleware_onion.inject(geth_poa_middleware, layer=0)

block = w3.eth.get_block('latest')
print(block)

You get a response like this:

AttributeDict({'difficulty': 2, 'proofOfAuthorityData': HexBytes('0xd98301010a846765746889676f312e31362e3135856c696e75780000c3167bdf10457371b76109ee8e5a5dbebf38ab1f2c858342aaf40c975db81a0040b3fc49789fd5709416496e771dd25d6ea8cc35da056476ba881031f3719a47d8d9a40501'), 'gasLimit': 79737643, 'gasUsed': 21995790, 'hash': HexBytes('0xc683c3c4c3a9670e5eda3ce18fa9597a2c5b45105faccbe2dc83ade7028340ea'), 'logsBloom': HexBytes('0x5d637f7bef671793400ce4758b9e337b20f9ce6f55bc4dda759a13d63deb9dbc0628ffcb88be1abedf993e7310de07fb3f3fc2d9a37eaf1bf7e0eb46afb56fca3cd58ff325ccf73c99e3de299ff273ed70fcc6fee7522849ee5fa19b85fb9e638544f6be0b2f694da5dff25390e5a8f16e4c46ebabdf6cef77a6e7f8f7a1979e15a1eae8564d9b2c54afff346ff5198b1a7d35ffd8aebbdccb113762a9b8cd34b386d2dcfd8a4393765773547afa94777af580ff2a8337ff1f76f18f80eafff8e3b99c860f40ce93b0e05cbbba2652e32dff1d3c757e7e3dceb3ff2b9926e1addab9ecb5b50bfb7df726220ce56baa7bf98e6c0fcdc224c5d53a8a825073b4a9'), 'miner': '0xE9AE3261a475a27Bb1028f140bc2a7c843318afD', 'mixHash': HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'), 'nonce': HexBytes('0x0000000000000000'), 'number': 17955668, 'parentHash': HexBytes('0xcf1581b4012dd3027b0f805953735063a7c5a34deb4883e6e0913c077bc748fa'), 'receiptsRoot': HexBytes('0x12b3694a7bf062d741dd17f68acb6d10d335ba58b35319d71695dd8f121c41bc'), 'sha3Uncles': HexBytes('0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'), 'size': 41677, 'stateRoot': HexBytes('0xc9a22a89c11c0b624cb5e515342bb46d3fbef9420dae600e71593c733e388e1c'), 'timestamp': 1653019232, 'totalDifficulty': 35690982, 'transactions': [HexBytes('0x665cbb473367ee5631d7ac6fba5b2d2fdc43bc6ed6414048f1b7ecfa07777ba4'), HexBytes('0x8d53df9b10b22352449e4328d7eb8303ccf301977eb5168821b8f71e18a27c85'), HexBytes('0xfefcd03d6a36737c85dbc90b7936f0d39ff032d505372e41eb253ed83b889b70'), HexBytes('0x2f63f70a29c8c2af3e59433d0bf820c177aa0fba983843652fe658060e44bc86'), HexBytes('0xc51e949e4fafb4750986b427bdf8c6c95ef3b96712cd3e9fc1091d1cbf818750'), HexBytes('0x99135d20be874c4d223819940d0b0309b0dbf613688dda4c70706cb98effb041'), HexBytes('0xaf5637270189c6cf5e7fdd16c86f04bdcae9e39d33934cbceb29c6524bd21971'), HexBytes('0x4c223c072650a38e30df8d5d959569bec99e46c60db82492f0f8c10fb82e70ac'), HexBytes('0x5ed7cac023c037d431175492977c9be9f0eb29bbab9d74df4d3a7ac3fdc512ab'), HexBytes('0xdb7731f83f8daf815c020192169733de8ba6e4e0b10ee0450d5412060eb9416e'), HexBytes('0xb0d49cea0640b40b7d6b9cd2144fd7d212d46d296826d047719c50fd4c7da817'), HexBytes('0xfb6e009fe6526da7917b2a2d6abd4b6a3db54f9bdac479d149c10a4b0cae68b8'), HexBytes('0xe15a7e124713442b1e8c64265b5c5d79dfc4aca804385ec6d7f1c5614bc003bc'), HexBytes('0xfd68e041e00869ab8d370a41f9071e1edfc8d76bccd38d4139e988f60b9f154a'), HexBytes('0x6b30db2c453255045817a75870b2f3f9f2fb1d109505b8b7ba3ab044fd143a76'), HexBytes('0x35babc167d4d7f9f00ad9e9fd74e15c8e04f65a585de03c4652be8c2af16bf37'), HexBytes('0xff464d0e1ca5555778dfbe0f16620fd6e3c228c9309d5ac70a34771458bc29fc'), HexBytes('0x84a46bac20983be26455be97f84205d603770ee214286946c52b049890ee9a73'), HexBytes('0x2634f7e4d91e6ebfad9993e601b81920e59f4f3b85b34cbbd27317f88771ec8d'), HexBytes('0xe81cc9623a3af37b51fadcd04e9a920e67d37e4f342b308b13941ea367ef0730'), HexBytes('0x6844dd779735dd190dfd16ba76c7753ade01665d21878c4204cf020d8f39c647'), HexBytes('0x5861b391d1c4ff12028c7ac74e633c2a7a97c9ac3420555c125321311fbde3af'), HexBytes('0x44ece8085d142d1893251f673efa28a801a8383f79b5c69d30e8a38a4687d948'), HexBytes('0xed2d7f924d849d5206ce06be0bcd72a52933fdd226a94f610ecd7c7e1244ef21'), HexBytes('0x7fa1b137be8f3cbae42ab4a74da663ebc6830e38271252987db1c26f8209f607'), HexBytes('0xa00c23a009ed3016c5716ef6ffa35f7cfc4d7cc8533f1581959041d0fd48bda7'), HexBytes('0xfeb45e962057fc993c191a141b051e92e83404f3b2982e5403c3dabcd2f7143d'), HexBytes('0xecb1608c359816001a4952773c71aaf51ca2e8990f2a599351cdecea24f55cc1'), HexBytes('0x49bb0d08da97e4648ed433b231e29ddbeb1d3602ae6914d406b14ee42cf6b009'), HexBytes('0xd8fab0f526c5faf44dd5a5191902751e93aaec40abe820a7e96b1f58240136a3'), HexBytes('0x14f177bfdae6605175f6c68767dd83540fa0d2c8345ec69bd6a71f0468a41bba'), HexBytes('0x251317924b858783aa6562dcbcd6201df52d1208a000c909d5de8cdb6fbaf61f'), HexBytes('0xba0378d6e984f3b1348b73197a4b17325fbd29be6b2612746c8e70d42d071424'), HexBytes('0x03d614d3f0c0c7b1fb6d9637a180b9459321126aac71c021eb429f61f6b5a00a'), HexBytes('0x0fc8eb5f00736a24fc28b1d37eb4a8abf56f308bf3aa60907bc9b43424e48641'), HexBytes('0x748483d5fccce6eb495705e515d03e66ea88ec40d55a938bf1462a3cba4cc44c'), HexBytes('0x24d6a36ede4268ec3ffcf3877d3303c9c97c28cc05cbf07b8c944331952f8324'), HexBytes('0x8717f6996e5dc91d3c6c685e52bfeffad734502e575e27f725cab454559c60df'), HexBytes('0xba97d5f7fb5392116b97a8300003aefa02ca39668ae655f57f0d20d018d8c970'), HexBytes('0xc78b6788ff84182681df57e6a54bac85feadddd72f7b5e269a4d6448d8a7662f'), HexBytes('0x9aef8ae3edb22438375e9e322e7dabd4236ea9e9c23f59a3605bbd1afb6e347a'), HexBytes('0x96efd9229779488fd27ab5ccf780515998059b10af13b7ebc7107eb0e29df1ad'), HexBytes('0xcf2d920420278e9ed1ff4d12c292ad4b03d654278ec03dc7eccee6f589b6df54'), HexBytes('0x74cb2930f3eeebce8d845bda2bcdc4f698e471687129c03860bc39413c88ddcd'), HexBytes('0x83fd26bbc7fcc8110ce36dd057d7900344cad2bbd6a497da88e69b7ec6aff9de'), HexBytes('0x0d1c3fd4083a4cbb1f82e0d02fac7b66fa40d3d67a0fb8df9058f3513d039898'), HexBytes('0xc330d9c375bcaee5ab0b9a66a95f62c2c4263b11b488bbe0c73bca19d7fd9fb0'), HexBytes('0x4f283aee96b4fdcb21cb2e1145c297d6a25649505868fe7e320983c9c81e959c'), HexBytes('0xa950ff16692db2cd4191a53b015cd7851ca50d8e33bdb71e2bf23683e83c3e39'), HexBytes('0x28118300d8839f4396b4db4e06bb1ebae23f82bbbf2e996b1e20036a5ccf8135'), HexBytes('0xb61f977bf312343c80d0f62c68e98c873d3ae991347e2047f6886cd59d4d5a56'), HexBytes('0x1b941be2d47088977a55c9f05f2ccc93d7f7fa2e6dc9f0a13cfc0039b004e5c4'), HexBytes('0x262de24222990609b0d524a0f0594f6569f47087d414469e522f81332361bd47'), HexBytes('0x9d2bcc99efed603e782004a01eb1897a2639bab26d1853e04ce4219e5be7963d'), HexBytes('0xe7f1701f56a1276bf0c03139dbde6a2c83f4e429d44bfbfc235bad0a30bebbe5'), HexBytes('0x28b6872dde2c72a557289c6921d3a1f2d2e4286204c4a1854316c49097bdc707'), HexBytes('0xfb557117b8391d6aecc10c3314c93eac7564fda597a466a0a63d431c50026273'), HexBytes('0x0302f06188a9d8f3a96a7c0649bce8cb818bb64e5057701c3317b43df8294d0c'), HexBytes('0x13bd6bf74ce911e60d7f9f5764a2ea0bbc1818d6fcea944d573ef63b29941796'), HexBytes('0x277190c3d39ac440ebced7ef54f2fa6152657e7af50ca8e24c5ce4a49315ba38'), HexBytes('0x4f727a4be0200259655cb7fddbf78126c6868607053566de639c9a4ddfcc38c1'), HexBytes('0x3fc00649acbd249b1b4fdc60041f039a850af3944f1ffca4416cba0ef42c5820'), HexBytes('0x6a42d3035be138cf3d3a147381a657619b3a25a9f7e3eaba1c3ded17595f52e4'), HexBytes('0x01f969cb99a726ccd0f5513b522d220eaadf2b3f3abe8d682a335bc8bfdd1010'), HexBytes('0x826de34175b4a279fe6d2db4c6d5d5b256cc1b0a121ae4027024e41793daaeb2'), HexBytes('0x6dce77b995342d5261b6dfa39ece19183014938f912bdff789d82212ac9ab890'), HexBytes('0xfd28bf5c7a30385a32198ec207cce3809494e8471c57676d8340e38f927add5c'), HexBytes('0x13f29072c5478c199860d86822da7a878441636475c162a5e17c7d0c498ad2f5'), HexBytes('0xcb235b1f41d67857e72625b9f08f3488cb922b7b79b1f833946bd197eba7f867'), HexBytes('0xedb942e8dfca033a6385a451faf0729950d687b1208772ff8d322d612117555c'), HexBytes('0x50f973089370d26420a736aefa49b4646e16b0a08fbe0c517bd7d1a0ce3678ee'), HexBytes('0x33343872dc2cdc74624f169de704d04f4076e7234c3db2cb49cf928934d4fafe'), HexBytes('0x390e3bbc11a463be461eb5d489168936885050827acc041230e27feb3b80b764'), HexBytes('0xd1d83eed761608ad7d174e99437d2926d641d38c7ff5d32281cb219a10b8ce58'), HexBytes('0x946ffb738daa14296b4974f26804fec2de04dc12ac7ba4d2a480b539741dcc85'), HexBytes('0x71807601c18d427c9d2f27428b145f4189e62a7eec3417c960def2580dea6687'), HexBytes('0x0eb38ef6c33ac8d131f0e6559235b73b9fc05eb990ece04fd32ca39c43eb4e7c'), HexBytes('0xba60680ee42443b24539142508cf7ba9dca72cde2f810c07977ffef8fcae47d8'), HexBytes('0xd133723ae2ea4b0ab523b15fba8087141a0d451221d1af2fc72ee51a6a41b04b'), HexBytes('0xb11e144da60e0da78c928e24cf7eef5d74d754454d6575876476199dd0097748'), HexBytes('0x4ebad82e42e9d9689bed155730809525354c5a4e654d77be5aa9e48c50a9b25d'), HexBytes('0x72fbe1c2101a96a5934cb79d100f7386400299847c6824db1a57edfa7185231d'), HexBytes('0xf4ee439f9a7b3ee6608e4f379a363f7728925791e92bc8021cf2d4e5f13c5c97'), HexBytes('0x3370280e4d0908c23c23c214ce3b858f6046fc9c2b6a16b18bab68f83047ffbd'), HexBytes('0x61b7ed6b84cbbbe69a84a0c63fbf00fe567ff77d21116cba67168a112bce78eb'), HexBytes('0x271d677759ac1fda6c1dfc3e4dd6bef3659202291b1b43ef37f58cd90b95ade7'), HexBytes('0x02b9163d56fe071ca75173f8a2beb1a19f436ce3e723d8b526d647ad1b1928ac'), HexBytes('0x8c993b0e0f4137e5ad87090df6662199c2d34116877ff0166e732a96e2539e63'), HexBytes('0xf5ba189b0e7329958cad337c6ca2d3fbe3db228251d18d6350e8056db36537c8'), HexBytes('0x136fc20a596afb9a60c684cd991b18886a36ba70a8861609ee97c7fddd953c24'), HexBytes('0x2ca8640256a49a6f14167fb1c33f05b81023d3661172501262e70bcb867972a9'), HexBytes('0x21ab75d75dfef9707a24fc9a29dcc40cc3134d20f1a4517c38b43334be0b8a1a'), HexBytes('0x025bccc8f63e629011e5d38d5f6ee64226980507557c4b41307ea5860a1fdfcc'), HexBytes('0x80ce6ce95ba0f73ba38336a89cfe9c220760406dba468d231134af4fc5fa3b2c'), HexBytes('0x36feed10e876b0b9d1363a7ca65ddfac8e8ad447ab70713b98c9fe4f3e3d8e1b'), HexBytes('0xe88a2fbca9298de7549e5c86bc28a3fcee24a10b637481baca20dea086e239d5'), HexBytes('0x8877c74a95fe1caf0fc09d4fec3c4f8c730b85c7d3e81efb947854747af26cbd'), HexBytes('0xf29d05d867a96ab3b8edb7c81ded5625b82d05ec0c00f9c6c438884ef6fed5a8'), HexBytes('0x86236921dd22d85a82c7cf4e26defb5bacac1e320447455474f66137005b9415'), HexBytes('0xe805a5b72cc80daaded9b7389276127610c12d92091faf58b1bcaf92a7043074'), HexBytes('0xd745265d68f40fb8dadc5f27e4a0cfb5a35e2db5d97e3a1ca751a630f06f7c88'), HexBytes('0x6cf6cb40885035acf73874633a63c98a87e6afb24f34a86743a74fdbf64400ab'), HexBytes('0xd772a0aef321533c72098e967c1ef872a23fc4b2a7a0c2fc9ca433c78b77c7ab'), HexBytes('0x87798b2687e8cc633de2142849be8795600526c364caee87281131b4eb61c575'), HexBytes('0x6c79c1b43d21d1b73bc54fb7982fdcf1cdff90aecc6829edff99f35f25ceb733'), HexBytes('0xa075e1f28893ad61a6ddbbaa36a49ca12dc873f78f408c975a367dada3dcc5a0'), HexBytes('0xbb7661df98b8594498c27a4e6c10b2c60f42e4bab34945c739e5b12ac5c11284'), HexBytes('0x0a29e0742bfbbdea910ef3844b9051f5e24a1d8caeb4e67c96f61d2ceaf31512'), HexBytes('0xdaa1dfa10c51556d37735710210664c1a923bcb61c93d6c2de79129958766ef4'), HexBytes('0x23c33b345e1eda4038d4c5e34c235f43604e28cfd1d3048e44131ffa468a54ed'), HexBytes('0x12d6051a3b9b18b729bbedb6ee76de5108530dbf84713761b58a1cefd0c8c81e'), HexBytes('0x1bdaddcb552c78f38100def21dab9e2212ab8eb13983b5eea29f31f74b5946b5'), HexBytes('0x48da2b7b0356ac90eae747406564347ae8be88bc5adf9138d199461861921235'), HexBytes('0x078ed412a6db830ccec8236a9aad486bf87a1d04defc7d9f34082d9f8c75da52'), HexBytes('0x33b4e9a05703ecb7da1fbce412885705ccfc4d1fd1a0ba9f13e80b4cc1b309c3'), HexBytes('0xba003dd30e3bc52f26ce515675f8bcfae4c87987357e2db9a2da47b1601a32ca'), HexBytes('0xdcd7866d3538ca10d60d9d3f12413f74b60004669737192238dc379abf295c37'), HexBytes('0x5ff3800caba63f2fae6f03859e91c5cedcf03af2d0d9ff4b317e61689db8abea'), HexBytes('0x9bf9e3fc32ae3ca2c8fdddb794cd73e074977ddbb65b4b8c593286c9623fe90c'), HexBytes('0x55eaa86c1372389b5bbabc2089a48d1fb0c65d8e25b59fc335871e660455b723'), HexBytes('0xe57b9c6ced9b87aa71d10fbdc00702ad85ec3bed500373647130efcaa6eff5fc'), HexBytes('0x0ad32ae96b3b080a00122318de2d8cd7218c75d03b28de2744a7d029b8552e76'), HexBytes('0x451c3da627ea4cc4fcfb27575abad865a2e504bd3d84ba78559e83bbac7bdb67'), HexBytes('0x044ada4c7437280bb59ea4f03135ddda2184f529a5706d1133e7f35fd5cb50f5')], 'transactionsRoot': HexBytes('0xc85ccf7a2f8466115acaf202cfbb6ee9a3b0e17a285dbd632252bb57418f063b'), 'uncles': []})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.