0.0.1 • Published 6 months ago

@gravity-bridge/provider v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Provider

Simple provider to query the Althea-L1 rest api.

Querying an Account for Sequence and Account Number

const restOptions = {
    method: 'GET',
    headers: { 'Content-Type': 'application/json'},
    // mode: 'no-cors', // This option will break the request in a confusing way when cors support is available
}
// Note that the node will return a 400 status code if the account does not exist.
queryEndpoint = `https://althea.zone:1317${generateEndpointAccount(account)}`;
const res = await fetch(
    queryEndpoint,
    restOptions,
).json()

Broadcasting a signed Tx

    const postOptions = {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        // Broadcast Mode Block waits for the Tx to be included in a block, may timeout
        body: generatePostBodyBroadcast(signedTx, BroadcastMode.Block),
    }

    const broadcastEndpoint = `https://althea.zone:1317${generateEndpointBroadcast}`

    const broadcastPost = await fetch(
        broadcastEndpoint,
        postOptions,
    )

    const res = await broadcastPost.json()

    // Result may contain the Tx execution response, including the events log
0.0.1

6 months ago