A Provider is an abstraction of a connection to the Theta Network, providing a concise, consistent interface to standard Theta blockchain node functionality.
This is the default and most commonly used provider.
const chainId = thetajs.networks.ChainIds.Mainnet; // By default, the provider will find the RPC URL to use. However, you can pass your own custom RPC url as the second arg. const provider = new thetajs.providers.HttpProvider(chainId); // If you run a Theta node on your local computer, and want to connect to the local node, you can set up the provider like this const providerForCustomNetwork = new thetajs.providers.HttpProvider('myprivatechain', 'http://localhost:16888/rpc');
const address = "0x000...000"; const account = await provider.getAccount(address);
const address = "0x000...000"; const count = await provider.getTransactionCount(address);
const blockHash = "0x0000...0000"; const block = await provider.getBlock(blockHash);
const blockHeight = "7801192"; const block = await provider.getBlock(blockHeight);
const blockHeight = await provider.getBlockNumber();
Updated over 2 years ago