https://github.com/duneanalytics/sim-idx-ts
https://github.com/duneanalytics/sim-idx-ts
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/duneanalytics/sim-idx-ts
- Owner: duneanalytics
- Created: 2025-06-20T10:48:09.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-23T11:14:23.000Z (12 months ago)
- Last Synced: 2025-06-23T11:19:55.306Z (12 months ago)
- Language: TypeScript
- Size: 48.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @duneanalytics/sim-idx
[](https://badge.fury.io/js/%40duneanalytics%2Fsim-idx)
[](https://www.npmjs.com/package/@duneanalytics/sim-idx)
[](https://opensource.org/licenses/MIT)
[](https://github.com/duneanalytics/sim-idx-ts/actions/workflows/on-pull-request.yml)
[](https://github.com/prettier/prettier)
[](https://www.typescriptlang.org/)
A TypeScript library for writing Sim IDX apps.
## Installation
```bash
npm install @duneanalytics/sim-idx
# or
yarn add @duneanalytics/sim-idx
# or
pnpm add @duneanalytics/sim-idx
```
## API Reference
### App Creation
```typescript
import { create } from '@duneanalytics/sim-idx';
interface Env {
CUSTOM_VAR: string;
}
const c = create();
```
### Database Client
```typescript
import { db } from '@duneanalytics/sim-idx';
// Get database client from Hono context
const client = db.client(context);
```
### Blockchain Types
```typescript
import { address, bytes32, uint256, int256 } from '@duneanalytics/sim-idx';
import { Address, Bytes, Uint, Int } from '@duneanalytics/sim-idx';
// Address type
const walletAddress = address('wallet_address');
// Bytes types (1-32 bytes)
const hash = bytes32('transaction_hash');
const shortData = bytes16('short_data');
// Integer types
const balance = uint256('balance');
const signedValue = int256('signed_value');
```
## Middlewares
The library provides a middleware for authentication.
When a valid Sim IDX API key is submitted in the `Authorization` header (please see [the documentation for authentication options](https://docs.sim.dune.com/idx/authentication#api)),
your API will receive the API key name in the `X-IDX-AUTHENTICATED-API-KEY-NAME` header. The authentication middleware uses this header to decide if a request is authenticated or not.
```typescript
import { App, middlewares } from '@duneanalytics/sim-idx';
const app = App.create();
app.use('*', middlewares.authentication);
```
*Note: In non-production environments, the authentication middleware will be disabled.*
## Environment Variables
The library expects these environment variables:
- `DB_CONNECTION_STRING`: Your database connection string
- `NODE_ENV`: Set to `production` for production environments.
## Development
```bash
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build the library
pnpm build
# Lint code
pnpm lint
# Format code
pnpm fix:prettier
```
## Deploying
1. First, update `package.json` with the next version number (and merge that)
1. Then, create a new tag in the format of `v*.*.*` (check
https://github.com/duneanalytics/sim-idx-ts/tags for the latest tag) and
increase it accordingly.
Creating a new tag will run a Github action that will build & publish the
library to npm.
1. Create a new release on GitHub with the same version number.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- 📖 [Documentation](https://github.com/duneanalytics/sim-idx-ts#readme)
- 🐛 [Report a bug](https://github.com/duneanalytics/sim-idx-ts/issues)
- 💬 [Discussions](https://github.com/duneanalytics/sim-idx-ts/discussions)