Smart Contracts API

Deploy Contract

Deploy a WASM smart contract to RougeChain.

POST /api/v2/contract/deploy

FieldTypeRequiredDescription
wasmstringBase64-encoded WASM bytecode
deployerstringDeployer's public key (hex)
noncenumberNonce for deterministic address (default: 0)

Response:

{
  "success": true,
  "address": "a1b2c3d4e5f6...",
  "wasmSize": 12345,
  "txHash": "4520936071b9..."
}

Contract deploy fee: wasmSize × 0.000001 XRGE

Call Contract

Execute a method on a deployed contract (mutating — creates an on-chain tx).

POST /api/v2/contract/call

FieldTypeRequiredDescription
contractAddrstringContract address (hex)
methodstringMethod name to call
callerstringCaller's public key
argsobjectJSON arguments
gasLimitnumberMax fuel (default: 10,000,000)

Response:

{
  "success": true,
  "returnData": { ... },
  "gasUsed": 1500,
  "events": [],
  "txHash": "b226a36688f0...",
  "error": null
}

Contract call fee: gasUsed × 0.000001 XRGE

Get Contract Metadata

GET /api/contract/:addr

Returns contract metadata: address, deployer, code hash, creation timestamp, WASM size.

{
  "success": true,
  "contract": {
    "address": "86fe93e2...",
    "deployer": "test-deployer",
    "code_hash": "a1b2c3...",
    "wasm_size": 711,
    "created_at": 1774401569985
  }
}

Read Contract Storage

Full State Dump

GET /api/contract/:addr/state

Returns all key-value pairs in the contract's persistent storage.

{
  "success": true,
  "state": {
    "count": "42",
    "owner": "alice"
  },
  "count": 2
}

Single Key Lookup

GET /api/contract/:addr/state?key=<hex_key>

Reads a single key from storage.

{
  "success": true,
  "key": "636f756e74",
  "value": "3432",
  "valueUtf8": "42"
}

Get Contract Events

GET /api/contract/:addr/events?limit=50

Returns indexed events emitted by the contract.

{
  "success": true,
  "events": [
    {
      "contract_addr": "86fe93e2...",
      "topic": "transfer",
      "data": "{\"from\":\"alice\",\"to\":\"bob\",\"amount\":100}",
      "block_height": 620,
      "tx_hash": "c3d4e5f6..."
    }
  ],
  "count": 1
}

List All Contracts

GET /api/contracts

Returns all deployed contracts with their metadata.

{
  "success": true,
  "contracts": [
    {
      "address": "86fe93e2...",
      "deployer": "test-deployer",
      "code_hash": "a1b2c3...",
      "wasm_size": 711,
      "created_at": 1774401569985
    }
  ],
  "count": 1
}