Developer Integration

Send blockchain-native emails from smart contracts, AI agents, and applications

Quick Reference

Contract:outlayer.near
Project ID:zavodil.near/near-email
API Base:api.outlayer.fastnear.com
Address space:alice.near = alice@near.email

Use 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

MethodBest ForPayment
Smart Contract (Rust)On-chain notificationsDeposit (unused refunded)
Payment Key (HTTPS)Server-side agents, high volumePre-paid balance (USDC)
NEAR TransactionBrowser wallets, direct signingDeposit (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

  1. 1Go to OutLayer Dashboard → Payment Keys
  2. 2Create a new key and add USD balance
  3. 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

ActionDescriptionEncryption
send_email_plaintextSend email (PUBLIC on-chain)None
send_emailSend email (private, only recipient decrypts)ECIES
get_emailsFetch inbox and sent emailsECIES
delete_emailDelete email by IDECIES
get_email_countGet inbox/sent countsNone
get_send_pubkeyGet sender's pubkey for encryptionNone

Limits

LimitTransaction ModePayment Key Mode
Max response size1.5 MB25 MB
Max file per attachment5 MB5 MB
Max total email size7 MB7 MB
Max attachments per email1010

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