Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 43 additions & 40 deletions docs/HyperSync-LLM/hypersync-complete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ Let's look at the core concepts in the example code:
### 1. Initialize the Client

```javascript
import { HypersyncClient } from "@envio-dev/hypersync-client";

// Initialize Hypersync client
const client = HypersyncClient.new({
url: "http://eth.hypersync.xyz", // Change this URL for different networks
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz", // Change this URL for different networks
apiToken: process.env.ENVIO_API_TOKEN!,
});
```

Expand All @@ -194,15 +196,14 @@ let query = {
fieldSelection: {
// Only return fields we need
log: [
LogField.Data,
LogField.Address,
LogField.Topic0,
LogField.Topic1,
LogField.Topic2,
LogField.Topic3,
"Data",
"Address",
"Topic0",
"Topic1",
"Topic2",
"Topic3",
],
},
joinMode: JoinMode.JoinTransactions, // How to join related data
};
```

Expand Down Expand Up @@ -246,13 +247,13 @@ One of HyperSync's most powerful features is the ability to retrieve only the fi
```javascript
fieldSelection: {
// Block fields
block: [BlockField.Number, BlockField.Timestamp],
block: ["Number", "Timestamp"],

// Log fields
log: [LogField.Address, LogField.Topic0, LogField.Data],
log: ["Address", "Topic0", "Data"],

// Transaction fields
transaction: [TransactionField.From, TransactionField.To, TransactionField.Value],
transaction: ["From", "To", "Value"],
}
```

Expand All @@ -274,12 +275,8 @@ HyperSync allows you to control how related data is joined:
This example (from the quickstart repo) streams all Uniswap V3 events from the beginning of Ethereum:

```javascript

import {
HypersyncClient,
LogField,
JoinMode,
} from "@envio-dev/hypersync-client";
import { keccak256, toHex } from "viem";
import { HypersyncClient } from "@envio-dev/hypersync-client";

// Define Uniswap V3 event signatures
const event_signatures = [
Expand All @@ -294,8 +291,9 @@ const event_signatures = [
const topic0_list = event_signatures.map((sig) => keccak256(toHex(sig)));

// Initialize Hypersync client
const client = HypersyncClient.new({
url: "http://eth.hypersync.xyz",
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});

// Define query for Uniswap V3 events
Expand All @@ -308,15 +306,14 @@ let query = {
],
fieldSelection: {
log: [
LogField.Data,
LogField.Address,
LogField.Topic0,
LogField.Topic1,
LogField.Topic2,
LogField.Topic3,
"Data",
"Address",
"Topic0",
"Topic1",
"Topic2",
"Topic3",
],
},
joinMode: JoinMode.JoinTransactions,
};

const main = async () => {
Expand All @@ -335,13 +332,22 @@ HyperSync supports 70+ EVM-compatible networks. You can change networks by simpl

```javascript
// Ethereum Mainnet
const client = HypersyncClient.new({ url: "http://eth.hypersync.xyz" });
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});

// Arbitrum
const client = HypersyncClient.new({ url: "http://arbitrum.hypersync.xyz" });
const client = new HypersyncClient({
url: "https://arbitrum.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});

// Base
const client = HypersyncClient.new({ url: "http://base.hypersync.xyz" });
const client = new HypersyncClient({
url: "https://base.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});
```

See the Supported Networks page for a complete list.
Expand Down Expand Up @@ -375,15 +381,12 @@ You're now ready to build with HyperSync! Here are some resources for diving dee
- curl Examples - Test queries directly in your terminal
- Complete Getting Started Guide - More comprehensive guidance

## API Token for Production Use
## API Token

For development, you can use HyperSync without an API token. For production applications, you'll need to get an API token and update your client initialization:
An API token is required to use HyperSync. Get an API token and set it as an environment variable:

```javascript
const client = HypersyncClient.new({
url: "http://eth.hypersync.xyz",
bearerToken: "your-api-token-here",
});
```bash
export ENVIO_API_TOKEN="your-api-token-here"
```

Congratulations! You've taken your first steps with HyperSync, bringing ultra-fast blockchain data access to your applications. Happy building!
Expand Down Expand Up @@ -1931,13 +1934,13 @@ To use an API token, pass it as a `bearer_token` when creating a HyperSync clien


```typescript
const client = HypersyncClient.new({
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz",
bearerToken: process.env.HYPERSYNC_BEARER_TOKEN,
apiToken: process.env.ENVIO_API_TOKEN!,
});
```




```python
Expand Down
2 changes: 1 addition & 1 deletion docs/HyperSync/api-tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To use an API token, pass it as a `bearer_token` when creating a HyperSync clien
<TabItem value="typescript" label="TypeScript/JavaScript">

```typescript
const client = HypersyncClient.new({
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});
Expand Down
74 changes: 38 additions & 36 deletions docs/HyperSync/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ Let's look at the core concepts in the example code:
import { HypersyncClient } from "@envio-dev/hypersync-client";

// Initialize Hypersync client
const client = HypersyncClient.new({
url: "http://eth.hypersync.xyz", // Change this URL for different networks
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz", // Change this URL for different networks
apiToken: process.env.ENVIO_API_TOKEN!,
});
```

Expand All @@ -87,15 +88,14 @@ let query = {
fieldSelection: {
// Only return fields we need
log: [
LogField.Data,
LogField.Address,
LogField.Topic0,
LogField.Topic1,
LogField.Topic2,
LogField.Topic3,
"Data",
"Address",
"Topic0",
"Topic1",
"Topic2",
"Topic3",
],
},
joinMode: JoinMode.JoinTransactions, // How to join related data
};
```

Expand Down Expand Up @@ -139,13 +139,13 @@ One of HyperSync's most powerful features is the ability to retrieve only the fi
```javascript
fieldSelection: {
// Block fields
block: [BlockField.Number, BlockField.Timestamp],
block: ["Number", "Timestamp"],

// Log fields
log: [LogField.Address, LogField.Topic0, LogField.Data],
log: ["Address", "Topic0", "Data"],

// Transaction fields
transaction: [TransactionField.From, TransactionField.To, TransactionField.Value],
transaction: ["From", "To", "Value"],
}
```

Expand All @@ -168,11 +168,7 @@ This example (from the quickstart repo) streams all Uniswap V3 events from the b

```javascript
import { keccak256, toHex } from "viem";
import {
HypersyncClient,
LogField,
JoinMode,
} from "@envio-dev/hypersync-client";
import { HypersyncClient } from "@envio-dev/hypersync-client";

// Define Uniswap V3 event signatures
const event_signatures = [
Expand All @@ -187,8 +183,9 @@ const event_signatures = [
const topic0_list = event_signatures.map((sig) => keccak256(toHex(sig)));

// Initialize Hypersync client
const client = HypersyncClient.new({
url: "http://eth.hypersync.xyz",
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});

// Define query for Uniswap V3 events
Expand All @@ -201,15 +198,14 @@ let query = {
],
fieldSelection: {
log: [
LogField.Data,
LogField.Address,
LogField.Topic0,
LogField.Topic1,
LogField.Topic2,
LogField.Topic3,
"Data",
"Address",
"Topic0",
"Topic1",
"Topic2",
"Topic3",
],
},
joinMode: JoinMode.JoinTransactions,
};

const main = async () => {
Expand All @@ -228,13 +224,22 @@ HyperSync supports 70+ EVM-compatible networks. You can change networks by simpl

```javascript
// Ethereum Mainnet
const client = HypersyncClient.new({ url: "http://eth.hypersync.xyz" });
const client = new HypersyncClient({
url: "https://eth.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});

// Arbitrum
const client = HypersyncClient.new({ url: "http://arbitrum.hypersync.xyz" });
const client = new HypersyncClient({
url: "https://arbitrum.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});

// Base
const client = HypersyncClient.new({ url: "http://base.hypersync.xyz" });
const client = new HypersyncClient({
url: "https://base.hypersync.xyz",
apiToken: process.env.ENVIO_API_TOKEN!,
});
```

See the [Supported Networks](/docs/HyperSync/hypersync-supported-networks) page for a complete list.
Expand Down Expand Up @@ -268,15 +273,12 @@ You're now ready to build with HyperSync! Here are some resources for diving dee
- [curl Examples](/docs/HyperSync/hypersync-curl-examples) - Test queries directly in your terminal
- [Complete Getting Started Guide](/docs/HyperSync/hypersync-usage) - More comprehensive guidance

## API Token for Production Use
## API Token

For development, you can use HyperSync without an API token. For production applications, you'll need to [get an API token](/docs/HyperSync/api-tokens) and update your client initialization:
An API token is required to use HyperSync. [Get an API token](/docs/HyperSync/api-tokens) and set it as an environment variable:

```javascript
const client = HypersyncClient.new({
url: "http://eth.hypersync.xyz",
bearerToken: "your-api-token-here",
});
```bash
export ENVIO_API_TOKEN="your-api-token-here"
Comment on lines +280 to +281
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is better than showing hardcoding the token in the code 🗡️

```

Congratulations! You've taken your first steps with HyperSync, bringing ultra-fast blockchain data access to your applications. Happy building!