@polkadot/rpc-provider/https
name: HttpProvider
description: The HTTP Provider allows sending requests using HTTP to a HTTP RPC server TCP port. It does not support subscriptions so you won't be able to listen to events such as new blocks or balance changes. It is usually preferrable using the WsProvider.
example:
import Api from '@polkadot/api/promise';
import HttpProvider from '@polkadot/rpc-provider/http';
const provider = new HttpProvider('http://127.0.0.1:9933');
const api = new Api(provider);
see: WsProvider
Hierarchy
HttpProvider
Implements
Constructors
constructor
⊕ new HttpProvider(endpoint?: string): HttpProvider
Defined in http/index.ts:40
Parameters:
| Name | Type | Default value | Description |
|---|---|---|---|
Default value endpoint |
string |
defaults.HTTP_URL | The endpoint url starting with http:// |
Returns: HttpProvider
Accessors
hasSubscriptions
gethasSubscriptions(): boolean
Defined in http/index.ts:55
summary: true when this provider supports subscriptions
Returns: boolean
Methods
clone
▸ clone(): HttpProvider
Implementation of ProviderInterface.clone
Defined in http/index.ts:62
description: Returns a clone of the object
Returns: HttpProvider
disconnect
▸ disconnect(): void
Implementation of ProviderInterface.disconnect
Defined in http/index.ts:69
description: Manually disconnect from the connection
Returns: void
isConnected
▸ isConnected(): boolean
Implementation of ProviderInterface.isConnected
Defined in http/index.ts:77
summary: Whether the node is connected or not.
Returns: boolean
true if connected
on
▸ on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void
Implementation of ProviderInterface.on
Defined in http/index.ts:85
summary: Events are not supported with the HttpProvider, see WsProvider.
description: HTTP Provider does not have 'on' emitters. WebSockets should be used instead.
Parameters:
| Name | Type |
|---|---|
| type | ProviderInterface$Emitted |
| sub | ProviderInterface$EmitCb |
Returns: void
send
▸ send(method: string, params: Array<any>): Promise<any>
Implementation of ProviderInterface.send
Defined in http/index.ts:92
summary: Send HTTP POST Request with Body to configured HTTP Endpoint.
Parameters:
| Name | Type |
|---|---|
| method | string |
| params | Array<any> |
Returns: Promise<any>
subscribe
▸ subscribe(types: string, method: string, params: Array<any>, cb: ProviderInterface$Callback): Promise<number>
Implementation of ProviderInterface.subscribe
Defined in http/index.ts:114
summary: Subscriptions are not supported with the HttpProvider, see WsProvider.
Parameters:
| Name | Type |
|---|---|
| types | string |
| method | string |
| params | Array<any> |
| cb | ProviderInterface$Callback |
Returns: Promise<number>
unsubscribe
▸ unsubscribe(type: string, method: string, id: number): Promise<boolean>
Implementation of ProviderInterface.unsubscribe
Defined in http/index.ts:123
summary: Subscriptions are not supported with the HttpProvider, see WsProvider.
Parameters:
| Name | Type |
|---|---|
| type | string |
| method | string |
| id | number |
Returns: Promise<boolean>