• Encodes an OracleJob definition into a binary format

    Parameters

    • data: string | IOracleJob | Record<string, any>

      OracleJob definition in various formats:

      • String: JSON with optional comments
      • IOracleJob: Protocol buffer object
      • Record: Plain object with tasks array

    Returns Buffer

    Serialized OracleJob as Buffer

    If validation or encoding fails

    // From JSON string
    const encoded1 = encodeOracleJob(`{
    "tasks": [
    {"httpTask": {"url": "https://api.coinbase.com/v2/prices/BTC-USD/spot"}}
    ]
    }`);

    // From plain object
    const encoded2 = encodeOracleJob({
    tasks: [
    {httpTask: {url: "https://api.coinbase.com/v2/prices/BTC-USD/spot"}}
    ]
    });
    • Uses normalizeOracleJob() for initial validation and normalization
    • Encodes using Protocol Buffers delimited format
    • Returns a Node.js Buffer suitable for blockchain transactions