Skip to content

Examples

Check out some example policies below.

Allowlist a specific smart contract or program interaction

ts
{
    version: '1.0',
    name: 'Allowlisted contracts',
    chain_type: 'ethereum',
    method_rules: [{
        method: 'eth_sendTransaction',
        rules: [
            {
                name: 'Allowlist the USDC address on Base',
                conditions: [
                    {
                        field_source: 'ethereum_transaction',
                        field: 'to',
                        operator: 'eq',
                        value: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                    },
                    {
                        field_source: 'ethereum_transaction',
                        field: 'chain_id',
                        operator: 'eq',
                        value: '8453'
                    }
                ],
                action: 'ALLOW'
            }
        ]
    }],
    default_action: 'DENY'
}

Configure a max transfer value of the native token (ETH, SOL)

ts
{
    version: '1.0',
    name: 'Native token transfer maximums'
    chain_type: 'ethereum',
    method_rules: [{
        method: 'eth_sendTransaction',
        rules: [{
            name: 'Restrict ETH transfers to a maximum value',
            conditions: [
                {
                    field_source: 'ethereum_transaction',
                    field: 'value',
                    operator: 'leq',
                    value: '500000000'
                },
            ],
            action: 'ALLOW'
        }]
    }],
    default_action: 'DENY'
}

Configure a max transfer value of an ERC20 or SPL token

ts
{
    version: '1.0',
    name: 'ERC20 maximums'
    chain_type: 'ethereum',
    method_rules: [{
        method: 'eth_sendTransaction',
        rules: [{
            name: 'Restrict USDC transfers on Base to be less than or equal to some value'
            conditions: [
                {
                    field_source: 'ethereum_transaction',
                    field: 'to',
                    operator: 'eq',
                    value: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                },
                {
                    field_source: 'ethereum_transaction',
                    field: 'chain_id',
                    operator: 'eq',
                    value: '8453'
                },
                {
                    field_source: 'ethereum_calldata',
                    field: 'transfer.amount',
                    abi: [{
                        "inputs": [
                            {
                                "internalType": "address",
                                "name": "recipient",
                                "type": "address"
                            },
                            {
                                "internalType": "uint256",
                                "name": "amount",
                                "type": "uint256"
                            }
                        ],
                        "name": "transfer",
                        "outputs": [
                            {
                                "internalType": "bool",
                                "name": "",
                                "type": "bool"
                            }
                        ],
                        "stateMutability": "nonpayable",
                        "type": "function"
                    }],
                    operator: 'leq',
                    value: '500000000'
                }
            ],
            action: 'ALLOW'
        }]
    }],
    default_action: 'DENY'
}

Denylist recipients of a transaction

ts
{
    version: '1.0',
    name: 'Denylisted addresses',
    chain_type: 'ethereum',
    method_rules: [{
        method: 'eth_sendTransaction',
        rules: [{
            name: 'Deny interactions with the USDC contract',
            conditions: [
                {
                    field_source: 'ethereum_transaction',
                    field: 'to',
                    operator: 'eq',
                    value: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                },
            ],
            action: 'DENY'
        }]
    }],
    default_action: 'ALLOW'
}

Enforce policies across multiple RPC methods

ts
{
    version: '1.0',
    name: 'Example policy with multiple RPC methods',
    chain_type: 'ethereum',
    method_rules: [{
        method: 'eth_sendTransaction',
        rules: [{
            name: 'Deny interactions with the USDC contract',
            conditions: [
                {
                    field_source: 'ethereum_transaction',
                    field: 'to',
                    operator: 'eq',
                    value: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                },
            ],
            action: 'DENY'
        }]
    }, {
        method: 'personal_sign',
        rules: [{
            name: 'Only allow certain messages to be signed',
            conditions: [
                {
                    field_source: 'ethereum_message',
                    field: 'value',
                    operator: 'eq',
                    value: 'Hello world'
                },
            ],
            action: 'ALLOW'
        }]
    }],
    default_action: 'DENY'
}

Allow all requests for a given RPC method

ts
{
    version: '1.0',
    name: 'Example policy to allow all personal_sign requests',
    chain_type: 'ethereum',
    method_rules: [{
        method: 'personal_sign',
        rules: [{
            name: 'Allow all EIP191 messages to be signed',
            conditions: [{
                field_source: 'ethereum_message',
                field: 'value',
                operator: 'eq',
                value: '*' // Allow all
            }],
            action: 'ALLOW'
        }],
    }],
    default_action: 'DENY'
}