入力フィールド

ポリシー決定で利用可能なすべてのデータの完全なリファレンス

すべてのポリシー決定は、input オブジェクトを通じてリクエストデータにアクセスできます。このページでは、ポリシーで使用できるすべての利用可能なフィールドを文書化しています。

ネットワーク

これらのフィールドは、呼び出されているブロックチェーンネットワークとRPCメソッドを識別し、チェーン固有のポリシーを作成したり、特定の操作を制限したりできます。

input.chain

TypeExample Values
string"ethereum", "polygon", "arbitrum", "optimism", "base"

リクエストのブロックチェーンネットワーク識別子。このフィールドを使用して、特定のチェーンへのアクセスを制限したり、ネットワークごとに異なるポリシーを適用したり、特定のチェーンを完全にブロックしたりできます。

# Only allow transactions on Polygon and Base
allowed_chains := {"polygon", "base"}
 
deny if {
    not input.chain in allowed_chains
}
 
# Apply stricter limits on Ethereum mainnet
deny if {
    input.chain == "ethereum"
    input.usd_value > 1000
}

input.rpc_method

TypeExample Values
string"eth_sendTransaction", "eth_call", "eth_getBalance"

リクエストからのJSON-RPCメソッド名。これを使用して特定の操作を許可またはブロックします。たとえば、読み取り操作(eth_calleth_getBalance)を許可しながら、書き込み操作(eth_sendTransaction)を制限できます。

一部のメソッドはプラットフォームレベルで制限されており、ポリシーを介して有効にすることはできません。

# Only allow read-only methods
allowed_methods := {
    "eth_call",
    "eth_getBalance",
    "eth_getTransactionCount",
    "eth_getCode",
    "eth_getLogs"
}
 
deny if {
    not input.rpc_method in allowed_methods
}
 
# Block signing methods
deny if {
    input.rpc_method in {"eth_sign", "personal_sign", "eth_signTypedData"}
}

リクエスト元

これらのフィールドは、リクエスト元に関する位置情報を提供し、地理ベースのアクセス制御と地域規制への準拠を可能にします。

input.source_ip

TypeExample Values
string"192.168.1.1", "2001:db8::1"

リクエストを行っているクライアントのIPアドレス。これを使用して、IPベースの許可リスト/ブロックリストを作成したり、ソースベースのレート制限を実装したりできます。

IP解決

デフォルトでは、256 Blocksは接続しているクライアントのIPアドレスを使用します。リクエストが独自のインフラストラクチャを通じてプロキシされている場合、X-Forwarded-For ヘッダーを介して元のクライアントIPを渡すことができます - 256 Blocksはそのヘッダーから最初のIPアドレスを使用します。

これは以下の場合に便利です:

  • リクエストがバックエンドサーバーを通じてプロキシされている
  • エンドユーザーの実際のIPアドレスを渡す必要がある
  • 開発環境で異なるIPアドレスでポリシーをテストする

# Block specific IP addresses
blocked_ips := {"192.168.1.100", "10.0.0.50"}
 
deny if {
    input.source_ip in blocked_ips
}
 
# Only allow requests from known infrastructure
allowed_ips := {"203.0.113.10", "203.0.113.11"}
 
deny if {
    not input.source_ip in allowed_ips
}

input.source_country

TypeExample Values
string"US", "GB", "DE", "UNKNOWN", "PRIVATE", "LOCALHOST"

source_ip から導出された2文字の ISO 3166-1 alpha-2 国コード。地理的制限、規制コンプライアンス、または地域固有のポリシーにこれを使用します。

国マッピングは毎日更新されます。公開IPアドレスの精度は通常95%以上です。

特別な値

非公開IPアドレスの場合、国コードの代わりに以下の値が返されます:

ValueDescription
"PRIVATE"プライベートIP範囲(10.x.x.x、172.16-31.x.x、192.168.x.x)
"LOCALHOST"ループバックアドレス(127.x.x.x)
"LINK_LOCAL"リンクローカルアドレス(169.254.x.x)
"MULTICAST"マルチキャストアドレス(224.x.x.x - 239.x.x.x)
"RESERVED"予約済みアドレス(240.x.x.x+)
"UNKNOWN"ルックアップ失敗またはサポートされていないアドレスタイプ

# Block sanctioned countries
blocked_countries := {"KP", "IR", "CU", "SY", "RU"}
 
deny if {
    input.source_country in blocked_countries
}
 
# Only allow requests from specific regions
allowed_countries := {"US", "CA", "GB", "DE", "FR"}
 
deny if {
    not input.source_country in allowed_countries
    input.source_country != "PRIVATE"  # Allow internal/development traffic
}

トランザクションパラメータ

これらのフィールドは、JSON-RPCリクエストパラメータから抽出されます。すべてのアドレスは、一貫した比較のために 0x プレフィックス付きの小文字に正規化されています。

input.from_address

TypeExample Value
string (nullable)"0x742d35cc6634c0532925a3b844bc9e7595f..."

送信者のウォレットアドレス。これは、トランザクションまたは署名リクエストを開始している人を識別します。このフィールドを使用して、特定のウォレットの許可リスト/ブロックリストを実装したり、送信者に基づいて異なるポリシールールを適用したりします。

RPCメソッド別のソース

MethodParameter Location
eth_sendTransactionparams[0].from
eth_callparams[0].from
eth_signparams[0]
personal_signparams[1]
eth_signTypedDataparams[0]

# Only allow transactions from approved wallets
allowed_senders := {
    "0x742d35cc6634c0532925a3b844bc9e7595f...",
    "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606..."
}
 
deny if {
    not input.from_address in allowed_senders
}

input.to_address

TypeExample Value
string (nullable)"0x742d35cc6634c0532925a3b844bc9e7595f..."

トランザクションの受信者またはターゲットアドレス。これは、単純な転送の場合はウォレットアドレス、コントラクトとのやり取りの場合はコントラクトアドレスになります。新しいコントラクトをデプロイする場合、値は null です(コントラクト作成トランザクションには受信者がありません)。

RPCメソッド別のソース

MethodParameter Location
eth_sendTransactionparams[0].to
eth_callparams[0].to
eth_getBalanceparams[0]
eth_getTransactionCountparams[0]

# Block transactions to known malicious addresses
blocked_addresses := {
    "0x000000000000000000000000000000000000dead",
    "0x1234567890abcdef..."
}
 
deny if {
    input.to_address in blocked_addresses
}

input.contract_addresses

TypeExample Value
array of strings["0x742d35cc...", "0xa0b86991..."]

リクエストに関与するスマートコントラクトアドレスの配列。これは、ユーザーがどのコントラクトと相互作用できるかを制御するのに特に便利です。配列には、複数のコントラクトをクエリできる eth_getLogs のようなメソッドの場合、複数のアドレスが含まれる場合があります。

RPCメソッド別のソース

MethodParameter LocationNotes
eth_sendTransactionparams[0].todata または input フィールドが存在する場合のみ
eth_callparams[0].toコントラクトを呼び出す場合
eth_getCodeparams[0]ターゲットコントラクトアドレス
eth_getStorageAtparams[0]ターゲットコントラクトアドレス
eth_getLogsparams[0].address単一のアドレスまたは配列

# Only allow interactions with approved contracts (e.g., USDT and USDC)
approved_contracts := {
    "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
}
 
deny if {
    some addr in input.contract_addresses
    not addr in approved_contracts
}

input.value_wei

TypeExample Value
string (nullable)"0xde0b6b3a7640000" (1 ETH in hex)

転送されるネイティブトークンの値、16進数文字列としてweiで表現されます。WeiはETHの最小単位です(1 ETH = 10^18 wei)。これは生のオンチェーン値です - USDベースのポリシーには、代わりに input.usd_value を使用してください。

RPCメソッド別のソース

MethodParameter Location
eth_sendTransactionparams[0].value
eth_callparams[0].value

# Block transactions transferring more than 10 ETH (in wei)
# 10 ETH = 10 * 10^18 wei = 0x8ac7230489e80000
deny if {
    input.value_wei != null
    to_number(input.value_wei) > 10000000000000000000
}
 
# Block zero-value transactions to specific contracts
deny if {
    input.value_wei == "0x0"
    some addr in input.contract_addresses
    addr == "0x..."
}

input.gas_limit

TypeExample Value
string (nullable)"0x5208" (21000 in hex)

トランザクションが消費できるガスユニットの最大量、16進数文字列として表現されます。単純なETH転送は21,000ガスを使用し、コントラクトとのやり取りは通常それ以上を必要とします。

RPCメソッド別のソース

MethodParameter Location
eth_sendTransactionparams[0].gas
eth_callparams[0].gas

# Block transactions with excessive gas limits (potential spam/abuse)
# 1,000,000 gas = 0xf4240
deny if {
    input.gas_limit != null
    to_number(input.gas_limit) > 1000000
}
 
# Don't sponsor high-gas transactions
denyGasSponsor if {
    input.gas_limit != null
    to_number(input.gas_limit) > 500000
}

input.gas_price

TypeExample Value
string (nullable)"0x3b9aca00" (1 gwei in hex)

レガシー(EIP-1559以前)トランザクションのガス価格、16進数文字列としてweiで表現されます。代わりに max_fee_per_gas を使用するEIP-1559トランザクションの場合、このフィールドは null です。

RPCメソッド別のソース

MethodParameter Location
eth_sendTransactionparams[0].gasPrice
eth_callparams[0].gasPrice

# Block legacy transactions with extremely high gas prices
# 500 gwei = 500 * 10^9 = 0x746a528800
deny if {
    input.gas_price != null
    to_number(input.gas_price) > 500000000000
}
 
# Don't sponsor legacy transactions (prefer EIP-1559)
denyGasSponsor if {
    input.gas_price != null
    input.max_fee_per_gas == null
}

input.max_fee_per_gas

TypeExample Value
string (nullable)"0x77359400" (2 gwei in hex)

EIP-1559トランザクションのガスユニットあたりの最大合計手数料、16進数文字列として表現されます。これは送信者が支払う意思のある絶対的な最大値です(基本手数料 + 優先手数料)。EIP-1559トランザクションタイプの場合のみ存在します。

RPCメソッド別のソース

MethodParameter Location
eth_sendTransactionparams[0].maxFeePerGas

# Block transactions willing to pay excessive gas fees
# 1000 gwei = 1000 * 10^9 = 0xe8d4a51000
deny if {
    input.max_fee_per_gas != null
    to_number(input.max_fee_per_gas) > 1000000000000
}
 
# Only sponsor transactions with reasonable max fees
# 50 gwei = 50 * 10^9 = 0xba43b7400
denyGasSponsor if {
    input.max_fee_per_gas != null
    to_number(input.max_fee_per_gas) > 50000000000
}

input.max_priority_fee_per_gas

TypeExample Value
string (nullable)"0x3b9aca00" (1 gwei in hex)

EIP-1559トランザクションのガスユニットあたりの最大優先手数料(チップ)、16進数文字列として表現されます。これはインセンティブとしてブロックプロデューサーに渡される部分です。EIP-1559トランザクションタイプの場合のみ存在します。

RPCメソッド別のソース

MethodParameter Location
eth_sendTransactionparams[0].maxPriorityFeePerGas

# Block transactions with excessive priority fees (potential MEV manipulation)
# 10 gwei = 10 * 10^9 = 0x2540be400
deny if {
    input.max_priority_fee_per_gas != null
    to_number(input.max_priority_fee_per_gas) > 10000000000
}
 
# Require reasonable priority fees for sponsored transactions
# 2 gwei = 2 * 10^9 = 0x77359400
denyGasSponsor if {
    input.max_priority_fee_per_gas != null
    to_number(input.max_priority_fee_per_gas) > 2000000000
}

エンリッチされたデータ

これらのフィールドは、生のリクエストにあるものを超えた追加のコンテキストを提供するために256 Blocksによって計算されます。

input.usd_value

TypeExample Value
number (nullable)1500.50

トランザクションのネイティブトークン値(value_wei)のUSD相当額、現在の市場価格を使用して計算されます。これは、支出制限とスポンサーシップコントロールを実装するための最も一般的なフィールドです。

価格は、信頼できる価格フィード(Chainlinkなど)から毎分取得されます。トランザクションに値がない場合(たとえば、純粋なコントラクト呼び出し)、値は null になる可能性があります。

# Block transactions over $10,000
deny if {
    input.usd_value > 10000
}
 
# Don't sponsor transactions over $100
denyGasSponsor if {
    input.usd_value > 100
}
 
# Handle null values safely
deny if {
    input.usd_value != null
    input.usd_value > 50000
}

生データ

上記の構造化フィールドでは必要なものが提供されない高度なユースケース用です。

input.raw_params

TypeExample Value
array[{"from": "0x...", "to": "0x...", "value": "0x...", "data": "0x..."}]

元のリクエストからの完全な、変更されていないJSON-RPC params 配列。構造化された入力プロパティを通じて公開されていないフィールドにアクセスする必要がある場合に使用します。たとえば:

  • 関数シグネチャ検出のためのコントラクト呼び出しデータ(data フィールド)
  • EIP-2930トランザクションのアクセスリスト
  • カスタムまたは非標準フィールド

# Block ERC-20 transfer function calls
# Function signature: transfer(address,uint256) = 0xa9059cbb
deny if {
    params := input.raw_params[0]
    params.data != null
    startswith(params.data, "0xa9059cbb")
}
 
# Block ERC-20 approve function (0x095ea7b3)
deny if {
    params := input.raw_params[0]
    params.data != null
    startswith(params.data, "0x095ea7b3")
}
入力フィールド | 256 Blocks