Web3 Gateway Transactions

Example code snippets to query the indexer for transaction module related data. Used only when interacting with the Web3Gateway

Using gRPC

Fetch response for preparing a transaction

import { Msgs, IndexerGrpcTransactionApi } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'
import { EvmChainId } from '@injectivelabs/ts-types'

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcTransactionApi = new IndexerGrpcTransactionApi(endpoints.indexer)

const address = '0x...' // ethereum address
const chainId = EvmChainId.Sepolia
const message = { ... } as Msgs
const memo = '...'

const prepareTxResponse = await indexerGrpcTransactionApi.prepareTxRequest({
  address,
  chainId,
  message,
  memo
})

console.log(prepareTxResponse)

Fetch response for preparing a cosmos transaction

Fetch response for broadcasting transactions using the Web3Gateway

Use MsgBroadcasterWithPk to broadcast transactions within a node/CLI environment, which can be found in @injectivelabs/sdk-ts.

Use @injectivelabs/wallet-core's MsgBroadcaster class for more details on broadcasting a transactions in a browser environment.

Fetch response for broadcasting a cosmos transactions.

Fetch Web3Gateway Fee Payer

Last updated