Get Started
Global Parameters
Certain parameters are configured globally. These parameters may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, These global values will be used as defaults on the operations that use them. When such operations are called, there is a place in each to override the global value, if needed.
For example, you can set chainId
to 43114
at SDK initialization and then you do not have to pass the same value on calls to operations like getBlock. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
Available Globals
The following global parameters are available.
Name | Type | Required | Description |
---|---|---|---|
chainId | string | No | A supported EVM chain id, chain alias, or blockchain id. |
network | components.GlobalParamNetwork | No | A supported network type, either mainnet or a testnet. |
Example
import { AvaCloudSDK } from "@avalabs/avacloud-sdk";
const avaCloudSDK = new AvaCloudSDK({
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114", // Sets chainId globally, will be used if not passed during method call.
network: "mainnet",
});
async function run() {
const result = await avaCloudSDK.data.evm.blocks.getBlock({
blockId: "0x17533aeb5193378b9ff441d61728e7a2ebaf10f61fd5310759451627dfca2e7c",
chainId: "<YOUR_CHAIN_ID>", // Override the globally set chain id.
});
// Handle the result
console.log(result)
}
run();
Was this page helpful?