The HTTP Provider allows sending requests using HTTP. 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 createApi from '@polkadot/api'; import WsProvider from '@polkadot/api-provider/ws';
const provider = new WsProvider('http://127.0.0.1:9933')); const api = createApi(provider);
see: WsProvider
HttpProvider
⊕ new HttpProvider(endpoint: string
): HttpProvider
Defined in http/index.ts:35
Parameters:
Param | Type |
---|---|
endpoint | string |
Returns: HttpProvider
▸ isConnected(): boolean
Implementation of ProviderInterface.isConnected
Defined in http/index.ts:49
Whether the node is connected or not.
Returns: boolean
true if connected
▸ on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void
Implementation of ProviderInterface.on
Defined in http/index.ts:56
Events are not supported with the HttpProvider, see WsProvider.
Parameters:
Param | Type |
---|---|
type | ProviderInterface$Emitted |
sub | ProviderInterface$EmitCb |
Returns: void
▸ send(method: string
, params: Array
<any
>): Promise
<any
>
Implementation of ProviderInterface.send
Defined in http/index.ts:60
Parameters:
Param | Type |
---|---|
method | string |
params | Array <any > |
Returns: Promise
<any
>
▸ subscribe(types: string
, method: string
, params: Array
<any
>, cb: ProviderInterface$Callback): Promise
<number
>
Implementation of ProviderInterface.subscribe
Defined in http/index.ts:82
Subscriptions are not supported with the HttpProvider, see WsProvider.
Parameters:
Param | Type |
---|---|
types | string |
method | string |
params | Array <any > |
cb | ProviderInterface$Callback |
Returns: Promise
<number
>
▸ unsubscribe(type: string
, method: string
, id: number
): Promise
<boolean
>
Implementation of ProviderInterface.unsubscribe
Defined in http/index.ts:91
Subscriptions are not supported with the HttpProvider, see WsProvider.
Parameters:
Param | Type |
---|---|
type | string |
method | string |
id | number |
Returns: Promise
<boolean
>