Create a policy
You can create a policy using the Privy Dashboard, the NodeJS SDK, or the REST API.
Policies optionally have owners, which represent the signatures required to modify the policy after creation, see setting authorization signatures.
We highly recommend specifying an owner for your policy to ensure that only authorized parties can modify them. Without an owner, the policy can be updated by your app secret alone.
Use the PrivyClient
’s createPolicy
method to create a new policy.
Use the PrivyClient
’s createPolicy
method to create a new policy.
To create a new policy, make a POST
request to:
In the request headers, make sure to include Privy’s required authentication headers and headers that may be required for your app’s wallet API setup.
Body
In the request body, include the following:
Version of the policy. Currently, 1.0 is the only version.
Name to assign to policy.
Chain type for wallets that the policy will be applied to.
A list of Rule
objects describing what rules to apply to each RPC method (e.g.
'eth_sendTransaction'
) that the wallet can take. Learn more about
Rule
s.
The P-256 public key of the owner of the policy. If you provide this, do not specify an owner_id as it will be generated automatically.
The key quorum ID of the owner of the policy. If you provide this, do not specify an owner.
Once you have successfully created a policy, you can assign that policy to server wallets at creation.
Currently, the policy engine supports the eth_signTransaction
and eth_sendTransaction
RPC
methods and the ethereum_transaction
field source. We are actively expanding support
here.
Response
If the policy is created successfully, the response will include the request body as well as an additional unique id
field for the policy.
Unique ID for the policy.
Version of the policy. Currently, 1.0 is the only version.
Name to assign to policy.
Chain type for wallets that the policy will be applied to.
A list of Rule
objects describing what rules to apply to each RPC method (e.g.
'eth_sendTransaction'
) that the wallet can take. Learn more about
Rule
s.
The key quorum ID of the owner of the policy, whose signature is required to modify the policy.
Example
As an example, a sample request to create a new eth_sendTransaction
policy might look like the following:
A successful response will look like the following: