Injective | TS & dApps Docs
DocumentationInjective TS
  • Overview
  • Getting Started
    • Technical Concepts
    • Application Concepts
      • Calculations
        • Min Price Tick Size
        • Min Quantity Tick Size
      • Networks
      • CosmJs Support
    • Assets
      • Creating Tokens
      • Denom Client (deprecated)
      • Injective Lists
    • Running examples
  • Wallets
    • Getting Started
    • Accounts
    • Wallet Connections
    • Wallet Strategy
    • Offchain (Arbitrary) Data
  • Querying
    • Getting Started
    • Chain
      • Auction
      • Auth
      • Bank
      • Distribution
      • Exchange
      • Governance
      • IBC
      • Mint
      • Insurance Funds
      • Oracle
      • Peggy
      • Permissions
      • Staking
      • Tendermint
      • Wasm
      • WasmX
      • Token Factory
    • Indexer
      • Account
      • Auction
      • Derivatives
      • Explorer
      • Insurance Funds
      • Markets
      • Leaderboard
      • Mito
      • Oracle
      • Portfolio
      • Spot
      • Web3Gw Transactions
      • Streaming
        • Account
        • Auction
        • Derivatives
        • Oracle
        • Portfolio
        • Spot
        • Explorer
    • Ethereum (GraphQL)
  • Transactions
    • Getting Started
    • Cosmos
      • Ledger through Keplr Wallet
    • Ethereum
      • Ethereum Ledger
    • MsgBroadcaster
    • Private Key
    • Web3 Gateway
  • Core Modules (& examples)
    • Getting Started
    • Auction
    • AuthZ
    • Bank
    • Distribution
    • Exchange
    • Feegrant
    • Governance
    • IBC
    • Insurance
    • Peggy
    • Permissions
    • Staking
    • Tokenfactory
    • Wasm
  • Smart Contracts
    • Cosmwasm
      • Injective Name Service
      • Neptune Service
      • CW20 to Bank & Market Order in One Transaction
  • Bridges
    • Getting Started
    • Ethereum
    • IBC
    • Wormhole
  • Building Dapps
    • Getting Started
    • Configuring Nuxt
    • Configuring React
    • dApps Examples
      • Smart Contract
      • DEX
      • Bridge
      • Simple HTML example with Webpack
Powered by GitBook
On this page
  • Running the example
  • How does it work?
  1. Building Dapps
  2. dApps Examples

Simple HTML example with Webpack

PreviousBridge

Last updated 7 months ago

The is based on the .

Running the example

Clone the project repo:

git clone https://github.com/InjectiveLabs/injective-ts-webpack-example.git

Ensure you have npm installed and install dependencies:

cd injective-ts-webpack-example && npm install

Run the example:

npm start
....
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/, http://[::1]:8080/
....

Go to the http://localhost:8080/ in your browser. If you have a Kelr wallet set up and connected to the Injective testnet, you should see "Confirm Transaction" pop up window.

How does it work?

Transaction logic is in the src/sendTx.tx, which is loaded by src/index.html Webpack is used to put eveything together and serve on the local server endpoint.

The webpack.config.js file configures Webpack to bundle a TypeScript application starting from ./src/sendTx.ts, using ts-loader to transpile TypeScript files, and includes rules to handle .js and .json files appropriately. It resolves browser-compatible versions of Node.js core modules using the fallback option, enabling modules like buffer, crypto, and stream in the browser environment. The configuration utilizes HtmlWebpackPlugin to generate an HTML file based on src/index.html, and ProvidePlugin to automatically load Buffer and process variables globally. The bundled output is named bundle.js and placed in the dist directory, and the devServer is set up to serve content from ./dist for development purposes.

example
Cosmos transaction handling section