Private Policy
Introduction
Private policy is a special kind of policy, which is only supposed to be used by its owner. For example, when a CEX frequently sends transactions with its hot wallet, it will want to create a designated policy to use, other than trying to match a policy with rules every time.
Purpose
Using private policy has several benefits:
- The private policy will have a specific purpose, and the fund will not be used by anyone other than the owner, to ensure the safety and precise usage of the fund.
- The private policy rules can be set up as simple as possible, even allowing no whitelist to be set at all, making it much easier to create and maintain.
- The rule-matching step is simplified only to verify one policy, making the API return faster.
Setup
- When creating the policy through the google form , choose the
policy type
section asPrivate Policy
. This sets the create policytype
input parameter to 1, which is private policy. - No whitelist is required, not like a public policy that needs either
from
orto
whitelist. Owners can have the flexibility to set any whitelist or none as needed for private policy.
Usage
- The private policy can be used when calling
eth_isSponsorable
oreth_sendRawTransaction
APIs, which need to be called through the open platform for identity verification - An additional header
X-MegaFuel-Policy-Uuid
is also required, to specify which private policy the caller wants to use.
curl --location 'https://open-platform-ap.nodereal.io/{$apikey}/megafuel/{$chainId}' \
--header 'Content-Type: application/json' \
--header 'X-MegaFuel-Policy-Uuid: <the-private-megafule-policy-uuid-you-requested>' \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_sendRawTransaction",
"params": [
"<raw-tx-data>"
]
}'
FAQ
-
What if I write the wrong uuid in the header?
If the uuid does not exist or you write another owner's policy uuid, the transaction will not be sponsored. -
What if my policy is out of gas?
If the policy associated with the uuid in the header is out of gas or is limited by other restrictions, the transaction will not be sponsored. -
I want to access public policy but added
X-MegaFuel-Policy-Uuid
header, what will happen?
If you addedX-MegaFuel-Policy-Uuid
header in the request, it will be regarded as a request for private policy, and the public policy will not sponsor the transaction.
Useful information
Endpoints for Private Policy
- BNB Smart Chain (BSC)
- opBNB
Private Policy APIs
https://docs.nodereal.io/reference/private-policy-api
Private Policy Usage in SDK
- Go-SDK: Private Policy Usage in Go SDK
- Js-SDK: Private Policy Usage in Js SDK
Private Policy Example
- Go-SDK: Go SDK Example
- Js-SDK: Js SDK Example
Updated 2 months ago