Skip to content

Commit

Permalink
cli: add glif auth (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber authored Jan 5, 2024
1 parent 784368a commit 7bae995
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 16 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# meridian cli

## Authentication

Get a token from https://auth.node.glif.io/, then pass `GLIF_TOKEN=...` with
every CLI invocation.

## Ledger

Keep your HW ledger device connected and unlocked on the Ethereum app.

## Example

```bash
GLIF_TOKEN=abc node bin/current-round-index.js
```
7 changes: 5 additions & 2 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import { fileURLToPath } from 'node:url'

const {
IE_CONTRACT_ADDRESS = '0xaaef78eaf86dcf34f275288752e892424dda9341',
RPC_URL = 'https://api.node.glif.io/rpc/v1'
RPC_URL = 'https://api.node.glif.io/rpc/v1',
GLIF_TOKEN // https://auth.node.glif.io/
} = process.env

const provider = new ethers.JsonRpcProvider(RPC_URL, null, {
const fetchRequest = new ethers.FetchRequest(RPC_URL)
fetchRequest.setHeader('Authorization', `Bearer ${GLIF_TOKEN}`)
const provider = new ethers.JsonRpcProvider(fetchRequest, null, {
batchMaxCount: 1
})
// provider.on('debug', d => console.log(JSON.stringify(d, null, 2)))
Expand Down

0 comments on commit 7bae995

Please sign in to comment.