API Reference

Complete technical reference for InterLayer's JSON-RPC API, runtime pallets, and error codes.

JSON-RPC Methods

Chain Methods

chain_getBlock

Get block details by hash or number

// Request
POST /rpc
{"jsonrpc": "2.0", "method": "chain_getBlock", "params": ["0xABC..."], "id": 1}
// Response
{"jsonrpc": "2.0", "result": {"block": {...}, "justifications": null}, "id": 1}

chain_getHeader

Get block header by hash

{"jsonrpc": "2.0", "method": "chain_getHeader", "params": [], "id": 1}
// Returns latest header if params empty

chain_getFinalizedHead

Get hash of the last finalized block

{"jsonrpc": "2.0", "method": "chain_getFinalizedHead", "params": [], "id": 1}

MEL Custom Methods

mel_submitCrossVmTx

Submit atomic cross-VM transaction

// Request
{
"jsonrpc": "2.0",
"method": "mel_submitCrossVmTx",
"params": {
"from": "SS58_ADDRESS",
"atomic": true,
"calls": [
{ "vm": "EVM", "to": "0x...","data": "0x..." },
{ "vm": "SVM", "to": "7nYB...", "data": "..." }
]
}
}
Atomic=true: All calls succeed or all revert

mel_getVmState

Query VM-specific state

{"method": "mel_getVmState", "params": {"vm": "EVM", "address": "0x..."}}

mel_estimateGas

Estimate unified gas for cross-VM call

{"method": "mel_estimateGas", "params": [...]}
// Returns gas in unified units

State Methods

state_getStorage

Query chain state by storage key

{"method": "state_getStorage", "params": ["0x26aa394eea5630e07c48ae0c9558cef7"]}

state_getMetadata

Get runtime metadata

{"method": "state_getMetadata", "params": []}

Runtime Pallets

fee-distribution

Manages fee distribution across validators, lite clients, MPC nodes, and treasury.

set_distribution

Update fee distribution percentages (requires governance)

api.tx.feeDistribution.setDistribution(
{ validators: 40, liteClients: 20, mpcNodes: 20, treasury: 20 }
)

get_distribution

Query current fee distribution

await api.query.feeDistribution.currentDistribution()

mel-core

Core Multi-VM Execution Layer logic and routing.

execute_cross_vm

Execute cross-VM transaction

api.tx.mel.executeCrossVm(calls, atomic)

register_vm_adapter

Register new VM adapter (governance only)

api.tx.mel.registerVmAdapter(vmType, adapter)

mel-evm

EVM adapter for Solidity contract execution.

call

Call EVM contract method

api.tx.melEvm.call(to, data, value, gasLimit)

create

Deploy EVM contract

api.tx.melEvm.create(bytecode, value, gasLimit)

Error Codes

InvalidVmType

Code: 1000

Specified VM type not supported

Solution:
Use EVM, SVM, or PolkaVM

InsufficientGas

Code: 1001

Gas limit too low for operation

Solution:
Increase gas limit or use mel_estimateGas

AtomicExecutionFailed

Code: 1002

One or more calls in atomic bundle failed

Solution:
Check individual call errors in receipt

CrossVmCallReverted

Code: 1003

Target VM call reverted

Solution:
Check VM-specific error in receipt.vm_error

InvalidSignature

Code: 2000

Transaction signature invalid

Solution:
Verify private key and nonce

NonceT order

Code: 2001

Transaction nonce incorrect

Solution:
Use correct account nonce

InsufficientBalance

Code: 3000

Account balance too low

Solution:
Fund account or reduce transaction amount

WebSocket Subscriptions

chain_subscribeNewHeads

Subscribe to new block headers

const
unsubscribe = await api.rpc.chain.subscribeNewHeads((header) => {
console.log(`New block #${header.number}`);
});

state_subscribeStorage

Subscribe to storage changes

api.rpc.state.subscribeStorage([key], (changes) => { ... })