Full documentation on the OutLayer dashboard.
A simple WASI example that echoes back the input message with NEAR context information.
This example demonstrates how to:
- Read JSON input from stdin
- Access NEAR environment variables (
NEAR_SENDER_ID,NEAR_BLOCK_HEIGHT) - Output formatted JSON response
{
"message": "Hello, NEAR!"
}{
"echo": "user.near said \"Hello, NEAR!\" at block 123456789"
}cargo build --target wasm32-wasip1 --releaseThe compiled WASM will be at: target/wasm32-wasip1/release/echo-example.wasm
# Run tests
cargo test
# Test with echo
echo '{"message":"Hello, NEAR!"}' | cargo runPublish 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"
}The following NEAR environment variables are available:
NEAR_SENDER_ID- Account that requested the executionNEAR_BLOCK_HEIGHT- Block height when the request was madeNEAR_BLOCK_TIMESTAMP- Block timestamp (nanoseconds)NEAR_CONTRACT_ID- OffchainVM contract addressNEAR_REQUEST_ID- Unique request IDNEAR_MAX_INSTRUCTIONS- Instruction limit for this executionNEAR_MAX_MEMORY_MB- Memory limit in MBNEAR_MAX_EXECUTION_SECONDS- Time limit in seconds