CDP SDK TypeScript - v1.31.0
    Preparing search index...

    The namespace containing all Policy methods.

    Implements

    Index

    Constructors

    Methods

    • Lists policies belonging to the developer's CDP Project. Can be filtered by scope (project or account).

      Parameters

      • Optionaloptions: ListPoliciesOptions = {}

        Options for filtering and paginating the results

        • OptionalpageSize?: number

          The page size to paginate through the accounts.

        • OptionalpageToken?: string

          The page token to paginate through the accounts.

        • Optionalscope?: "project" | "account"

          The scope of the policies to return. If project, the response will include exactly one policy, which is the project-level policy. If account, the response will include all account-level policies for the developer's CDP Project.

      Returns Promise<ListPoliciesResult>

      A paginated list of policies

               const { policies } = await cdp.policies.listPolicies();
               const { policies } = await cdp.policies.listPolicies({
      scope: 'project'
      });
               // Get first page
      const firstPage = await cdp.policies.listPolicies({
      pageSize: 10
      });

      // Get next page using cursor
      const nextPage = await cdp.policies.listPolicies({
      pageSize: 10,
      pageToken: firstPage.pageToken
      });
    • Creates a new policy that can be used to govern the behavior of projects and accounts.

      Parameters

      • options: CreatePolicyOptions

        Options for creating the policy

        Options for creating a Policy.

        • OptionalidempotencyKey?: string

          The idempotency key to ensure the request is processed exactly once. Used to safely retry requests without accidentally performing the same operation twice.

        • policy: {
              scope: "project" | "account";
              description?: string;
              rules: (
                  | {
                      action: "reject"
                      | "accept";
                      operation: "signEvmTransaction";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
                  | { action: "reject"
                  | "accept"; operation: "signEvmHash" }
                  | {
                      action: "reject" | "accept";
                      operation: "signEvmMessage";
                      criteria: { type: "evmMessage"; match: string }[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "signEvmTypedData";
                      criteria: (
                          | {
                              type: "evmTypedDataField";
                              types: {
                                  types: Record<string, { name: ...; type: ... }[]>;
                                  primaryType: string;
                              };
                              conditions: (
                                  | { addresses: (...)[]; operator: (...) | (...); path: string }
                                  | {
                                      value: string;
                                      operator: (...) | (...) | (...) | (...) | (...);
                                      path: string;
                                  }
                                  | { match: string; path: string }
                              )[];
                          }
                          | {
                              type: "evmTypedDataVerifyingContract";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                      )[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "sendEvmTransaction";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmNetwork";
                              networks: ("base-sepolia" | "base")[];
                              operator: "in" | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "signSolTransaction";
                      criteria: {
                          type: "solAddress";
                          addresses: string[];
                          operator: "in" | "not in";
                      }[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "prepareUserOperation";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmNetwork";
                              networks: ("base-sepolia" | "base")[];
                              operator: "in" | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "sendUserOperation";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
              )[];
          }

          The policy definition to create. Contains the scope, description, and rules for the policy.

          • scope: "project" | "account"

            The scope of the policy. "project" applies to the entire project, "account" applies to specific accounts.

          • Optionaldescription?: string

            An optional human-readable description for the policy. Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.

          • rules: (
                | {
                    action: "reject"
                    | "accept";
                    operation: "signEvmTransaction";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
                | { action: "reject"
                | "accept"; operation: "signEvmHash" }
                | {
                    action: "reject" | "accept";
                    operation: "signEvmMessage";
                    criteria: { type: "evmMessage"; match: string }[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "signEvmTypedData";
                    criteria: (
                        | {
                            type: "evmTypedDataField";
                            types: {
                                types: Record<string, { name: ...; type: ... }[]>;
                                primaryType: string;
                            };
                            conditions: (
                                | { addresses: (...)[]; operator: (...) | (...); path: string }
                                | {
                                    value: string;
                                    operator: (...) | (...) | (...) | (...) | (...);
                                    path: string;
                                }
                                | { match: string; path: string }
                            )[];
                        }
                        | {
                            type: "evmTypedDataVerifyingContract";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                    )[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "sendEvmTransaction";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmNetwork";
                            networks: ("base-sepolia" | "base")[];
                            operator: "in" | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "signSolTransaction";
                    criteria: {
                        type: "solAddress";
                        addresses: string[];
                        operator: "in" | "not in";
                    }[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "prepareUserOperation";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmNetwork";
                            networks: ("base-sepolia" | "base")[];
                            operator: "in" | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "sendUserOperation";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
            )[]

            Array of rules that comprise the policy. Limited to a maximum of 10 rules per policy.

      Returns Promise<Policy>

      The created policy

      When the policy is invalid

               const policy = await cdp.policies.createPolicy({
      policy: {
      scope: "account",
      description: "Limits the amount of ETH in transaction",
      rules: [
      {
      action: "reject",
      operation: "signEvmTransaction",
      criteria: [
      {
      type: "ethValue",
      ethValue: "1000000000000000000",
      operator: ">",
      },
      ],
      },
      ],
      }
      });
               const idempotencyKey = uuidv4();

      // First call creates the policy
      const policy = await cdp.policies.createPolicy({
      policy: {
      scope: "account",
      description: "Limits the amount of ETH in transaction",
      rules: [
      {
      action: "reject",
      operation: "signEvmTransaction",
      criteria: [
      {
      type: "ethValue",
      ethValue: "1000000000000000000",
      operator: ">",
      },
      ],
      },
      ],
      },
      idempotencyKey
      });

      // Second call with same key returns the same policy
      const samePolicy = await cdp.policies.createPolicy({
      policy: { ... },
      idempotencyKey
      });
    • Retrieves a policy by its unique identifier.

      Parameters

      • options: GetPolicyByIdOptions

        Options containing the policy ID to retrieve

        Options for retrieving a Policy by ID.

        • id: string

          The unique identifier of the policy to retrieve. This is a UUID that's generated when the policy is created.

      Returns Promise<Policy>

      The requested policy

               const policy = await cdp.policies.getPolicyById({
      id: "__ID__"
      });

      console.log(policy.name);
      console.log(policy.rules);
    • Deletes a policy by its unique identifier. If a policy is referenced by an active project or account, this operation will fail.

      Parameters

      • options: DeletePolicyOptions

        Options containing the policy ID to delete

        Options for deleting a Policy.

        • id: string

          The unique identifier of the policy to delete. This is a UUID that's generated when the policy is created.

        • OptionalidempotencyKey?: string

          The idempotency key to ensure the request is processed exactly once. Used to safely retry requests without accidentally performing the same operation twice.

      Returns Promise<void>

      Void on successful deletion

               await cdp.policies.deletePolicy({
      id: "__ID__"
      });
               const idempotencyKey = uuidv4();

      // This operation is idempotent with the key
      await cdp.policies.deletePolicy({
      id: "__ID__",
      idempotencyKey
      });
    • Updates an existing policy by its unique identifier. This will apply the updated policy to any project or accounts that are currently using it.

      Parameters

      • options: UpdatePolicyOptions

        Options containing the policy ID and updated policy data

        Options for updating a Policy.

        • id: string

          The unique identifier of the policy to update. This is a UUID that's generated when the policy is created.

        • policy: {
              description?: string;
              rules: (
                  | {
                      action: "reject"
                      | "accept";
                      operation: "signEvmTransaction";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
                  | { action: "reject"
                  | "accept"; operation: "signEvmHash" }
                  | {
                      action: "reject" | "accept";
                      operation: "signEvmMessage";
                      criteria: { type: "evmMessage"; match: string }[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "signEvmTypedData";
                      criteria: (
                          | {
                              type: "evmTypedDataField";
                              types: {
                                  types: Record<string, { name: ...; type: ... }[]>;
                                  primaryType: string;
                              };
                              conditions: (
                                  | { addresses: (...)[]; operator: (...) | (...); path: string }
                                  | {
                                      value: string;
                                      operator: (...) | (...) | (...) | (...) | (...);
                                      path: string;
                                  }
                                  | { match: string; path: string }
                              )[];
                          }
                          | {
                              type: "evmTypedDataVerifyingContract";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                      )[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "sendEvmTransaction";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmNetwork";
                              networks: ("base-sepolia" | "base")[];
                              operator: "in" | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "signSolTransaction";
                      criteria: {
                          type: "solAddress";
                          addresses: string[];
                          operator: "in" | "not in";
                      }[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "prepareUserOperation";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmNetwork";
                              networks: ("base-sepolia" | "base")[];
                              operator: "in" | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
                  | {
                      action: "reject"
                      | "accept";
                      operation: "sendUserOperation";
                      criteria: (
                          | {
                              type: "ethValue";
                              ethValue: string;
                              operator: ">"
                              | ">="
                              | "<"
                              | "<="
                              | "==";
                          }
                          | {
                              type: "evmAddress";
                              addresses: `0x${string}`[];
                              operator: "in"
                              | "not in";
                          }
                          | {
                              type: "evmData";
                              abi: | "erc20"
                              | "erc721"
                              | "erc1155"
                              | readonly (
                                  | {}
                                  | {}
                                  | (
                                      { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                  )
                              )[];
                              conditions: { function: string; params?: (...)[] }[];
                          }
                      )[];
                  }
              )[];
          }

          The updated policy definition. Contains the description and rules for the policy.

          • Optionaldescription?: string

            An optional human-readable description for the policy. Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.

          • rules: (
                | {
                    action: "reject"
                    | "accept";
                    operation: "signEvmTransaction";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
                | { action: "reject"
                | "accept"; operation: "signEvmHash" }
                | {
                    action: "reject" | "accept";
                    operation: "signEvmMessage";
                    criteria: { type: "evmMessage"; match: string }[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "signEvmTypedData";
                    criteria: (
                        | {
                            type: "evmTypedDataField";
                            types: {
                                types: Record<string, { name: ...; type: ... }[]>;
                                primaryType: string;
                            };
                            conditions: (
                                | { addresses: (...)[]; operator: (...) | (...); path: string }
                                | {
                                    value: string;
                                    operator: (...) | (...) | (...) | (...) | (...);
                                    path: string;
                                }
                                | { match: string; path: string }
                            )[];
                        }
                        | {
                            type: "evmTypedDataVerifyingContract";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                    )[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "sendEvmTransaction";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmNetwork";
                            networks: ("base-sepolia" | "base")[];
                            operator: "in" | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "signSolTransaction";
                    criteria: {
                        type: "solAddress";
                        addresses: string[];
                        operator: "in" | "not in";
                    }[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "prepareUserOperation";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmNetwork";
                            networks: ("base-sepolia" | "base")[];
                            operator: "in" | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
                | {
                    action: "reject"
                    | "accept";
                    operation: "sendUserOperation";
                    criteria: (
                        | {
                            type: "ethValue";
                            ethValue: string;
                            operator: ">"
                            | ">="
                            | "<"
                            | "<="
                            | "==";
                        }
                        | {
                            type: "evmAddress";
                            addresses: `0x${string}`[];
                            operator: "in"
                            | "not in";
                        }
                        | {
                            type: "evmData";
                            abi: | "erc20"
                            | "erc721"
                            | "erc1155"
                            | readonly (
                                | {}
                                | {}
                                | (
                                    { payable?: boolean | undefined; constant?: boolean | undefined; gas?: number | undefined; } & ({ inputs: readonly AbiParameter[]; outputs: readonly AbiParameter[]; type: "function"; name: string; stateMutability: "pure" | ... 2 more ... | "payable"; } | { ...; } | { ...; } | { ...; })
                                )
                            )[];
                            conditions: { function: string; params?: (...)[] }[];
                        }
                    )[];
                }
            )[]

            Array of rules that comprise the policy. Limited to a maximum of 10 rules per policy.

        • OptionalidempotencyKey?: string

          The idempotency key to ensure the request is processed exactly once. Used to safely retry requests without accidentally performing the same operation twice.

      Returns Promise<Policy>

      The updated policy

      When the updated policy is invalid

               const updatedPolicy = await cdp.policies.updatePolicy({
      id: "__ID__",
      policy: {
      description: "Now with lower transaction limits",
      rules: [
      {
      action: "reject",
      operation: "signEvmTransaction",
      criteria: [
      {
      type: "ethValue",
      ethValue: "1000000000",
      operator: ">",
      },
      ],
      },
      ],
      },
      });
               const idempotencyKey = uuidv4();

      // This operation is idempotent with the key
      await cdp.policies.updatePolicy({
      id: "__ID__",
      policy: {
      description: "Modified Policy",
      rules: { ... }
      },
      idempotencyKey
      });