BNB Smart Chain
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
BNB Smart Chain
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Every BNB Smart Chain request you send through TheRPC must carry a valid API key. Unauthenticated traffic to the chainId 56 endpoint is rejected before it reaches a node. This guide explains where to generate that key, the two ways you can present it (in the https://bsc.therpc.io/YOUR_API_KEY URL path or as a Bearer header), the security habits that keep it from leaking, and how to read the JSON-RPC error you get back when authentication fails.
Alongside placing the token in the request path, TheRPC accepts the key through the standard Authorization header using the Bearer scheme, shown in the examples below. Whichever style you choose, the credential has to accompany every single call to the BNB Smart Chain gateway. There is no session or cookie, so a request that omits the key will not be processed.
When authentication fails, the BNB Smart Chain endpoint returns a JSON-RPC envelope whose error object carries code -32001 and a message like "Invalid authentication credentials", as shown below. The usual triggers are a missing key, a malformed token, a key that has been expired or revoked from the dashboard, or hitting your plan's rate ceiling. Inspect the code and message to tell an auth problem apart from a throttling one.
Keep your BNB Smart Chain key out of the codebase by loading it from an environment variable at runtime instead of hardcoding the literal token. A small .env entry plus the language snippets below let you read the value through process.env or os.getenv, so the same source ships safely across machines and the key never lands in version control.