Ethereum geliştiricilər tipik olaraq Ethereum nodlara asan qasmaq üçün Infura və ya Alchemy ilə bağlıdır. GetBlock bir çox zəncirli dəstək, cütlüyüzsüz özəlləşdiricilik və mükəmməl stabiliteti təmin edən atraktiv bir alternativdir. Bu tutorialda, Truffle + web3.js backendini Infura/Alchemy-dən GetBlock-a migratlaşdırmaq üçün necə ola biləcəksiniz. GetBlock ilə əlaqə saxlamaq, RVP-nin başlanğıcını qəbul etmək, “Trubet”ə qayıtmaq, Web3 İncəsənət İncəsənəti Depozitlər aparılır və Qiymət limitini dəyişdirmək və fərqləri izləmək. Sizə Truffle və Node.js ilə var olan bir Ethereum DApp projektinə ehtiyac var. Mən Infura və ya Alchemy (project ID və ya API şifreləri ilə) istifadə etdiyinizə və dağıtmaq üçün bir mnemonik və ya özel şifrelə ehtiyac var. Prerequisites: Niyə “Infura” və ya “Alchemy”dan “GetBlock”ə keçmək lazımdır? GetBlock allows you to connect to not just Ethereum but 55+ blockchain networks using JSON-RPC, REST, and WebSocket APIs. This allows you to use Ethereum, Bitcoin, BNB Smart Chain, Polygon, Solana, and a lot of others with one platform. Infura and Alchemy, meanwhile, have a shorter list of networks supported (Infura supports Ethereum primarily and some networks like IPFS or certain L2s, and Alchemy supports Ethereum and some chains but not BSC specifically). If your DApp can be more than Ethereum, the broad multi-chain support of GetBlock is a huge plus. Multi-chain support. Each of these providers has free plans, but their limitations and models are different. Infura's free plan conventionally provided around 50,000 requests per day (now measured as 3 million daily credits with some rate limiting). Alchemy's free tier offers up to 100 million compute units a month (Alchemy measures different RPC calls as different "compute units"). GetBlock's free tier is very developer-friendly: it offers 50,000 requests a day (reset daily) with a limit of 5 requests a second. Practically, 50k daily calls are sufficient for development and small DApps, and you can always upgrade in case you need more. The free plan is indeed free ("zero fees") and still allows access to all supported chains. The key takeaway here is that GetBlock's free plan should be more than sufficient for typical dev and testing demands. Generous free tier. GetBlock offers a 99.9% uptime guarantee with a stable 24/7 connection to blockchain networks. That is, you can expect a highly stable service for your DApp backend. Stability is also what Infura and Alchemy are famous for, but GetBlock's infrastructure is built to be rock-solid and scalable. Many developers appreciate the fact that GetBlock provides both shared nodes (with usage limits) and dedicated nodes for heavier workloads, so you have a way to scale up. The correct answer is that the platform is highly reliable, so you won't see variations in network uptime when you switch over – possibly except for better performance in certain instances. Stability and uptime. Son olaraq, GetBlock'un dashboardı çox böyük monitoring və analitik imkanlara malikdir, bu da bizə yaxın zamanda gələcək. Step 1: GetBlock hesabı üçün baxın İlk adım GetBlock hesabına baxmaqdır: Navigate to the GetBlock website and click on "Sign Up" (or directly visit the GetBlock dashboard sign-up page). You have a few sign-up options: Email/Password. Sign up using email and choose a password. Social Login. Use Google or GitHub to sign up immediately. Web3 Wallet. You can even sign up by connecting a MetaMask wallet (no email required). This is a great option for developers who are already set up on MetaMask. Sizin istədiyiniz metodu seçin və talimatları izləyin (yaxud, e-mailinizi təsdiq edin, əgər e-poçt girişini seçsəniz).GetBlock hesabınız bir və ya iki dəqiqə ərzində olmalıdır. Xatırladaq ki, “GetBlock” panelində API-nin terminallıqlarını, istifadəini izləməyi və ayarlaşdırma ayarlarını işləməyəcəksiniz.GetBlock panelində oturduğunuzda hər yerə baxın. Hesabınızın ayarlarında istifadəçi ID-nizi görəcəksiniz (bir zaman kömək lazımdırsa faydalı olarsınız), lakin daha da önemlisi, sonradan projekt terminallıqlarını konfigurasiya edəcəksiniz. Step 2: Get Your GetBlock RPC Endpoint (API Key və URL) Hesabat yaradılıb, Ethereum şəbəkəsi üçün bir RPC terminali yaratmaq lazımdır (ya da hər hansı bir ağına ehtiyacınız varsa). Bu, Infura / Alchemy yerində istifadə edəcəyiniz bir HTTP URL-ni (ve buna uyğun olan WebSocket URL-ni) verəcək. Yeni terminlər hazırlayın: GetBlock Dashboard-da “Create Endpoint” və ya “Add New Endpoint” düymələrini tapın. Select the blockchain network. As in our case, choose Ethereum from the list of available protocols. Then select the network type: For Ethereum Mainnet, choose Mainnet. For a testnet, choose the specific test network (GetBlock now supports Ethereum Sepolia). Bu terminal üçün bir adı / etiketi (t.b. "MyDApp Ethereum Mainnet") verin ki, birdən çox terminalı configure etsəniz izləmək asanlaşsın. Hazırlanma və ya yeniləmə işlətmə prosesi aparılır. Xatırladaq ki, RPC-nin URL-i sizin üçün belə olmalıdır: GetBlock sizə bir WebSocket URL (wss:// ilə başlayaraq) üçün aynı terminal üçün göstərə bilər, və aplicasiyanız WebSocketsə ehtiyac duyduğunda (subscriptions və ya canlı hadisələr üçün), bunu istifadə edə bilərsiniz. GetBlock API-nin anahtarını təhlükəsiz saxlayın. Onu public repos və ya client-side koduna qoymayın. Ən yaxşı praktika onu bir çevrimiçi varis olaraq saxlamaq və ya source control-dən başqa bir faili konfigür etməkdir. Sonrakı adımda çevrimiçi varislərlə göstərəcəyəm. Ötən Artıq istifadə etmək üçün hazır bir GetBlock endpoint URL-i və API-ni var. Step 3: GetBlock istifadə etmək üçün Truffle konfigurasiyasını dəyişdirin Sizin və ya VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir - artıq sorğu-suala ehtiyacı olmayan ulduzdu. truffle-config.js truffle.js require('dotenv').config(); const HDWalletProvider = require('@truffle/hdwallet-provider'); const INFURA_PROJECT_ID = process.env.INFURA_PROJECT_ID; const MNEMONIC = process.env.MNEMONIC; // or a private key module.exports = { networks: { ropsten: { provider: () => new HDWalletProvider(MNEMONIC, `https://ropsten.infura.io/v3/${INFURA_PROJECT_ID}`), network_id: 3, gas: 5500000, confirmations: 2, timeoutBlocks: 200, skipDryRun: true }, // ... other networks ... }, // ... other Truffle config ... }; İnfura URL'sini GetBlock URL'sinə (ve hər hansı Alchemy URL'sində də) yerləşdirməkdir.Gözəl xəbər GetBlock'un RPC'si də belə işləyir - siz bir terminal URL'sini və cəriməni təmin edirsiniz. Əgər sizin “Truffle” projektiniz artıq istifadə etmir (Onunla bağlı bir şey ola bilər ki, əgər infura/Alchemy vasitəsilə dağıtmışsınızsa) Bu kütləvi Truffle-nin anahtarlarınızla transaksiyaları imzalamasına və onları uzaq düymə yoluyla göndərməyə imkan verir. HDWalletProvider istifadə edir. @truffle/hdwallet-provider npm install @truffle/hdwallet-provider Modifikasiya VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir. Filtrə Set VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir. və ya Misal olaraq, GetBlock ilə Ethereum Sepolia testnet istifadə etmək üçün: truffle-config.js .env GETBLOCK_API_KEY=<your_key_here> MNEMONIC PRIVATE_KEY require('dotenv').config(); const HDWalletProvider = require('@truffle/hdwallet-provider'); const PRIVATE_KEY = process.env.PRIVATE_KEY; // your wallet private key (hex string, no 0x) const GETBLOCK_KEY = process.env.GETBLOCK_API_KEY; // your GetBlock API key module.exports = { networks: { sepolia: { provider: () => new HDWalletProvider( PRIVATE_KEY, `https://eth.getblock.io/sepolia/?api_key=${GETBLOCK_KEY}` ), network_id: 11155111, // Sepolia network ID gas: 5500000, // Gas limit, adjust as needed confirmations: 2, // # of blocks to wait between deployments (optional) timeoutBlocks: 200, // # of blocks before a deployment times out (optional) skipDryRun: true // Skip dry run before migrations (recommended for public nets) }, // ... other networks (mainnet, etc) ... }, // ... rest of config ... }; Ana səhifə » Xəbərlər » URL-nin dəyişdirilməsi Bizimlə Bir neçə ildir ki, “Truffle”ı hər dəfə Xatırladaq ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir ki, bir neçə ildir. https://eth.getblock.io/... ?api_key= sepolia mainnet: { provider: () => new HDWalletProvider( PRIVATE_KEY, `https://eth.getblock.io/mainnet/?api_key=${GETBLOCK_KEY}` ), network_id: 1, gas: 5500000, gasPrice: 20e9, // e.g., 20 Gwei (you may adjust according to network conditions) confirmations: 2, timeoutBlocks: 200, skipDryRun: true } Nəticədə düzgün olaraq yerləşdirilməlidir. İnternetiniz üçün (Ethereum mainnet 1dir, Sepolia 11155111dir, etc.) network_id İŞİD GetBlock də yolda anahtarın daxil edilməsini dəstəkləyir (bir neçə misalda gördüyünüz kimi). İkisi də eşitmir. sorğu parametrini istifadə etmək daha tipikdir və şablonlarla işləmək asandır. Noteqə https://eth.getblock.io/<network>/?api_key=.. 4 - GetBlock ilə web3.js istifadə edin və test edin Konfranslarınızı göndərməzdən əvvəl, hər şeyin düzgün yapılandırılmış olduğunu kontrol etmək yaxşı fikirdir. Truffle Console. Run (or the name of the network you specified). This will launch a console with Web3 available interactively. Try running something as a test, such as this: . If everything is properly set up, this should display the current block number on that network via GetBlock. If you get a response, your connection is solid! truffle console --network sepolia await web3.eth.getBlockNumber() Node.js Script. Alternatively, you could test using web3.js in a standalone script. First, make sure you have web3 installed ( ), then create a simple script like below to get the latest block number: npm install web3 // test-getblock.js const Web3 = require('web3'); const RPC_URL = `https://eth.getblock.io/sepolia/?api_key=${process.env.GETBLOCK_API_KEY}`; const web3 = new Web3(RPC_URL); web3.eth.getBlockNumber() .then(num => console.log("Latest block number:", num)) .catch(err => console.error("Error connecting to GetBlock:", err)); Sizin çevrimiçi variabilərinizi yükləməyi unutmayın (bilirsiniz ki, Əsas səhifə » GETBLOCK_API_KEY » GETBLOCK_API_KEY » GETBLOCK_API_KEY Bir blok numarası yazırsa, siz web3.js vasitəsilə GetBlock-a işləmişsiniz. require('dotenv').config(); node test-getblock.js Əsas səhifə » Xəbərlər » Əsas səhifə ( Bir blokun və ya hesabın balansını ala bilmək kimi, işin işlədiyini daha da təsdiq etmək üçün daha çox çalışdıra bilərsiniz. eth_getBlockNumber const latestBlock = await web3.eth.getBlock('latest'); console.log("Latest block info:", latestBlock); Əgər bir şey yanlış olursa (təkcə, autentifikasiya hatası alırsınız), URL-dəki API-nin doğru olduğunu və hesabınızın pulsuz limitinin aşılmadığını kontrol edin (bir neçə istefa ilə çox az ola bilər). Əgər əvvəl Alchemy və ya Infura'nın web3 providerini kodda istifadə etmiş olsanız (yani, Alchemy özəlləşdirilən metodlarla bir Web3 müştəri və ya SDK-ni təqdim edir), GetBlock'a keçmək isə hala əsas Web3 metodlarını istifadə edəcəksiniz. Tipə görə Step 5: GetBlock-da Truffle Migrations və Testlər Son olaraq, həqiqi test – kontratlarınızı yerləşdirmək və DApp-i GetBlock ilə backend provideriniz kimi hosting etmək. Tramp isə Con Brennanı “çox pis oğlan” adlandırıb/Publika.az. Kontraktların qurulması truffle migrate --network sepolia VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir - artıq sorğu-suala ehtiyacı olmayan ulduzdu. Ethereum mainnet-ə dağıtdığınızda, dağıtıcı hesabınızda əmin-aman bir miktar ETH-yə sahib olduğunuzdan və gas qiymətlərinə dikkat edin. - Sizin GetBlock.com.az xəbər verir ki, “Infura” şirkəti “GetBlock” şirkəti “GetBlock” şirkəti “Ethereum” şirkəti “Ethereum” şirkəti ilə işləyir. truffle migrate --network mainnet mainnet Kontraktlarınızı çağırmaq üçün Truffle testləri və ya skriptləri varsa, onları GetBlock tərəfindən təqdim edilən ağda da test edə bilərsiniz: Təsadüfi testlər truffle test --network sepolia VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir - artıq sorğu-suala ehtiyacı olmayan ulduzdu. VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir - artıq sorğu-suala ehtiyacı olmayan ulduzlar var. Tədbirlər ( Hər şey, hər şey var, hər şey var, hər şey var. Bəlkə də gözləyən davranış eth_sendRawTransaction eth_call Sizin DApp'inizin backend-i GetBlock'da var! Migrasiya tamamdır. web3 çağırışlarınız GetBlock'un infrastrukturunu istifadə edir və smart kontratlarınız canlıdır. GetBlock-da API Key, Rate Limits və Monitoring işləmək VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir - artıq sorğu-suala ehtiyacı olmayan ulduzdu. İnfura URL-də bir projekt ID-ni istifadə edib; Alchemy də URL-də daxil olan formada (ya da özəlləşdirilmiş domaində) daha çox API-ni istifadə edib. GetBlock-in qasırğası da aynıdır – bir qasırğası (API Key) alacaqsınız və bunu RPC URL-yə daxil edirsiniz. funksiyal düzeydə, proqramınızın ancaq sonuncu URL-də daxil olmadan ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq ancaq etsin. API Key Setup xəritədə Üçüncüsü, “Free Level”də sərnişin limitləri var: Limitlər və limitlər. GetBlock Free Tier. 50,000 compute units per day and max 5 requests per second. In practice, 1 simple RPC call ≈ 1 CU (more complex calls like logs could be more counted, as with Alchemy's system). The 5 RPS restriction will make you not burst more than 5 requests in the same second on free tier. If so, subsequent calls may be refused with a rate-limit response. For all but the most busy DApps, 5 RPS is fine while developing – but if your backend scripts are making lots of concurrent calls, you may need to rate-limit them or consider switching to a more expensive plan (the one after this offers 25 RPS). Infura. Infura's free tier was circa 100k requests/day historically and since their new configuration, it's 6 million credits/day throughput of up to 2,000 credits/sec (which is roughly the equivalent of perhaps ~2000 simple calls/sec). Infura's generous free plan RPS is very kind, but note the fact that not all calls are 1 credit (some big calls are more credits). Either way, if your DApp wasn't hitting Infura's limits, it likely won't hit GetBlock's either, by similar scale. Alchemy. Alchemy's 100M free tier monthly of compute units is significant as well. They have no hard RPS fee, but intense usage will consume those compute units quickly. Alchemy bills calls (e.g., a simple ETH call might be 0.5 CU, a complex one 10 CUs, etc.). If you weren’t close to 100M units, you should be fine switching to 50k/day (≈1.5M/month) on GetBlock for dev. If 50k/day is not enough (e.g., if you are running a production app on a free plan – not typical), you might have to move to GetBlock's paid plans which offer much higher monthly CUs. GetBlock-un digər böyük aspektləri tam analizi ilə panelidir. Kontrol panelinizin ana sayfasında, günün üçün qalan CU-lar, aktualdır RPS küncünüz və son 24 saatda alınan toplu istəklərinizin öhdəliyini alırsınız. Bu, gündəlik limitinizə çatmadığınızı dərhal biləcəyinizi göstərir. Kullanış monitorinqini aparır. İstehsalların sayı müddət ərzində Reaksiya statusu (həqiqətən, heç bir hata olmadığınızı görmək üçün) Metod çağırma dağılımı (neçə RPC metodları ən çox çağırırsınız) Qiymət limitini atdığınızda (RPS limitini tapdığınızda) Bu metrikləri izləmək çox tövsiyə olunur, lakin siz dəyişdiyiniz halda.Əgər bir skripti yanlışlıqla yazdıysanız ki, ağı çağrılarla batırırsanız, kontrol panel istehlak hacminin artımını və ya 429-dən çox həcm-limit cavabını göstərəcək.Bu, DApp'inizin backend çağrılarını optimize etmək istəyən yerdir.Infura və Alchemy ayrıca dashboardlar təqdim edəcək, lakin GetBlock ilə olan avantajı, bir yerdən bütün çox zəncirli istifadəinizi izləyə bilərsinizdir. Beləliklə, GetBlock-un yeni planı kifayət deyil (bəlkə də appunuz genişlənir), Starter planı (~50M CUs / ay, ~1.6M / gün, 25 RPS) və Pro planı (600M / ay, 200 RPS) asan yeniləmələr var. Dərslərdən doğrudan yeniləmək mümkün deyil. Tədbir limitləri. GetBlock Free planı maksimum 2 access token (endpoints) üçün kömək edir. Bu, mainnet üçün birini, testnet üçün birini yaratmaq anlamına gelir – proqnozlarınızı və ya ortamlarınızı izolasiya edin. Hər terminalın öz API-nin və istifadə izləməsi vardır. Bu, Infura'nın "Project ID per project" metoduna bənzəyir. Bir çox terminallar var. Sürücülük üçün ən yaxşı praktikalar Mənim sizə önerdiyim budur: Maintain environment variables. Place your API keys and secrets (mnemonic/private key) in an file or in your system environment, not in source code. This makes switching endpoints easier and more secure. .env Test on a testnet first. While switching providers, attempt to deploy on a test network (Sepolia) with the help of GetBlock before working on mainnet. This makes sure that your setup is right. After confirmation, you can shift your mainnet setup. Compare behavior. It is a good idea to do some sanity checks after migration – i.e., get a known contract's data via Infura and via GetBlock and compare that the results are identical. They should be, since both are reading from Ethereum, but this can give confidence that GetBlock is in full sync (GetBlock does run full nodes, so it should be). WebSockets (if required). If your backend relies on WebSocket subscriptions (i.e., listening to events), GetBlock does offer that too. Simply use the URL in a Web3 WebsocketProvider. Ensure that your plan covers the throughput your subscriptions require (the same RPS limits apply to websockets). The majority of developers, however, use WebSockets in the frontend (with a library like MetaMask or Alchemy's subscription API). In purely backend contexts, WebSockets are less common, but it’s good to know GetBlock has the option. wss://go.getblock.io/xxxxxxx No frontend changes. Since this migration is backend-facing, your frontend (if you have one) doesn't have to change. If you were using MetaMask to connect to a testnet using Infura, you can still do so – MetaMask does not require GetBlock for connecting users (though GetBlock can also provide custom RPC endpoints for MetaMask). The separation of concerns (frontend vs. backend) remains. Sonrakı VVD - Hollandiyada futbolçu bu adla tanımır, orada VVD daha çox mərkəz-sağı təmsilən edən siyasi partiyanın adının qısaltması kimi bilinir - artıq sorğu-suala ehtiyacı olmayan ulduzdu.