Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Echo Ark

Full documentation on the OutLayer dashboard.

A simple WASI example that echoes back the input message with NEAR context information.

What it does

This example demonstrates how to:

  • Read JSON input from stdin
  • Access NEAR environment variables (NEAR_SENDER_ID, NEAR_BLOCK_HEIGHT)
  • Output formatted JSON response

Input Format

{
  "message": "Hello, NEAR!"
}

Output Format

{
  "echo": "user.near said \"Hello, NEAR!\" at block 123456789"
}

Building

cargo build --target wasm32-wasip1 --release

The compiled WASM will be at: target/wasm32-wasip1/release/echo-example.wasm

Testing Locally

# Run tests
cargo test

# Test with echo
echo '{"message":"Hello, NEAR!"}' | cargo run

Using with NEAR OutLayer

Publish the build and deploy it as a project:

outlayer upload target/wasm32-wasip1/release/echo-example.wasm
# prints SHA256 and: FastFS URL: https://main.fastfs.io/<you>/outlayer.near/<sha256>.wasm
outlayer deploy echo-example <FastFS URL>

Or in the dashboard: Projects → Create Project with the WASM URL and its SHA256. Then call it with:

  • Source: {"Project": {"project_id": "<you>/echo-example", "version_key": null}}
  • Response Format: Json
  • Input Data: {"message":"Hello from the blockchain!"}

The contract will receive a parsed JSON response:

{
  "echo": "alice.near said \"Hello from the blockchain!\" at block 123456789"
}

Environment Variables

The following NEAR environment variables are available:

  • NEAR_SENDER_ID - Account that requested the execution
  • NEAR_BLOCK_HEIGHT - Block height when the request was made
  • NEAR_BLOCK_TIMESTAMP - Block timestamp (nanoseconds)
  • NEAR_CONTRACT_ID - OffchainVM contract address
  • NEAR_REQUEST_ID - Unique request ID
  • NEAR_MAX_INSTRUCTIONS - Instruction limit for this execution
  • NEAR_MAX_MEMORY_MB - Memory limit in MB
  • NEAR_MAX_EXECUTION_SECONDS - Time limit in seconds

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages