Skip to content

Commit

Permalink
Merge pull request #3 from SubstrateLabs/hwwu/toolchain-update
Browse files Browse the repository at this point in the history
  • Loading branch information
steinwaywhw authored Aug 20, 2024
2 parents eb15ace + 73fbb1b commit a628357
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 732 deletions.
16 changes: 12 additions & 4 deletions _internal/_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
export SUBSTRATE_API_KEY=ENTER_YOUR_KEY

# Run the TypeScript example

# If using tsx:
cd typescript # Navigate to the typescript example
npm install # Install dependencies
ts-node example.ts # Run the example
npx tsx example.ts # Run the example

# If using Deno:
cd typescript
deno run example.ts

# Run the Python example

# If using Poetry:
cd python # Navigate to the python example
Expand All @@ -20,9 +28,9 @@ poetry run main # Run the example

# If using Rye:
# Update pyproject.toml to switch to Rye.
cd python # Navigate to the python example
rye sync # Install dependencies and build the example
rye run main # Run the example
cd python
rye sync
rye run main
```

</details>
Expand Down
28 changes: 28 additions & 0 deletions _internal/_template/typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Substrate Example Templates in Typescript

This is a Substrate example template written in Typescript. To run this example,

```bash
# Set your API key as an environment variable.
# Get one here https://www.substrate.run/dashboard/keys if this is your first time.
export SUBSTRATE_API_KEY=<your Substrate API key>

# Navigate to the python example directory.
cd typescript
```

To run the example with tsx (default), run the following.

```bash
npx tsx ./example.ts

# Or you can use the package.json scripts
npm run start
```

To run the example with Deno, uncomment the Deno sections in `example.ts` and
run the following.

```bash
deno run ./example.ts
```
6 changes: 4 additions & 2 deletions _internal/_template/typescript/example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env -S npx ts-node --transpileOnly
import { Substrate, ComputeText } from "substrate";
import { ComputeText, Substrate } from "substrate";

// Uncomment the following line if using Deno
// import process from "node:process";

async function main() {
const apiKey = process.env["SUBSTRATE_API_KEY"] || "YOUR_API_KEY";
Expand Down
Loading

0 comments on commit a628357

Please sign in to comment.