Developer Integration
Send blockchain-native emails from smart contracts, AI agents, and applications
Quick Reference
Contract:
outlayer.nearProject ID:
zavodil.near/near-emailAPI Base:
api.outlayer.fastnear.comAddress space:
alice.near = alice@near.emailUse Cases
NFT Marketplace
Notify users when their NFT is sold
DeFi Protocol
Alert users about liquidation risk
DAO Governance
Send voting reminders and proposal notifications
AI Agents
Enable agents to communicate via email
Integration Methods
| Method | Best For | Payment |
|---|---|---|
| Smart Contract (Rust) | On-chain notifications | Deposit (unused refunded) |
| Payment Key (HTTPS) | Server-side agents, high volume | Pre-paid balance (USDC) |
| NEAR Transaction | Browser wallets, direct signing | Deposit (unused refunded) |
1. Smart Contract Integration (Rust)
Smart contracts send emails by calling OutLayer's request_execution method.
Warning:Email content (to, subject, body) is stored publicly on the NEAR blockchain. Use
send_email_plaintext only for automated notifications.2. Payment Key (HTTPS API)
Pre-fund a payment key and make simple HTTPS calls. Best for server-side agents.
Setup Steps
- 1Go to OutLayer Dashboard → Payment Keys
- 2Create a new key and add USD balance
- 3Copy the key (format:
owner:nonce:secret)
Privacy:Use
send_email with ECIES encryption for private emails — only the recipient can decrypt. Examples below use send_email_plaintext for simplicity (content is public on-chain).3. NEAR Transaction (Per-Use)
Sign transactions directly with NEAR wallet. Attach deposit as a limit for computation costs — unused portion is automatically refunded.
Critical:NEAR Transaction results are in the
outlayer.near receipt's SuccessValue (base64-encoded JSON). Find the receipt where executor_id === 'outlayer.near'. Returns { "success": true, ... } directly — NO output wrapper!Privacy:Use
send_email with ECIES encryption for private emails — only the recipient can decrypt. Examples below use send_email_plaintext for simplicity (content is public on-chain).API Actions
| Action | Description | Encryption |
|---|---|---|
| send_email_plaintext | Send email (PUBLIC on-chain) | None |
| send_email | Send email (private, only recipient decrypts) | ECIES |
| get_emails | Fetch inbox and sent emails | ECIES |
| delete_email | Delete email by ID | ECIES |
| get_email_count | Get inbox/sent counts | None |
| get_send_pubkey | Get sender's pubkey for encryption | None |
Limits
| Limit | Transaction Mode | Payment Key Mode |
|---|---|---|
| Max response size | 1.5 MB | 25 MB |
| Max file per attachment | 5 MB | 5 MB |
| Max total email size | 7 MB | 7 MB |
| Max attachments per email | 10 | 10 |
Resource Limits (for NEAR Transactions)
When calling via NEAR transaction, use these resource limits:
{
"max_memory_mb": 512,
"max_instructions": 2000000000,
"max_execution_seconds": 120
}Resources
Go to near.email
Powered by NEAR Outlayer